Jump to content

HTTP file upload with $oHTTP (anonfile)


Recommended Posts

Hello, it's your annoying newbie here

And i (still) need help

i'm trying to work on something that upload a file to anonfile (because it dosnt any sort of loging in)

and i figured out this small code

everything works fine up until i try to upload a file, and it just sratight up dosn't work and i get an error from the server ((10) ERROR_FILE_NOT_PROVIDED)

so could someone help me

code (probably too much useless things):

#include <HTTP.au3>
; The data to be sent
$sPD = 'file=@test.txt'
$file = @ScriptDir & "/test.txt"

; Creating the object
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "https://api.anonfiles.com/upload", False)
$oHTTP.SetRequestHeader("Content-Type", "text/plain")

; Performing the Request
$oHTTP.Send($sPD)
$fileopen = FileOpen($file, 0)
$oHTTP.Send(FileRead($fileopen))
MsgBox(4096, "test", FileRead($fileopen))
FileClose($fileopen)

; Download the body response if any, and get the server status response code.
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status

If $oStatusCode <> 200 then
 MsgBox(4096, "Response code", $oStatusCode)
EndIf

; Saves the body response regardless of the Response code
 $file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists
 FileWrite($file, $oReceived)
 FileClose($file)

Thanks you all for your previous support on my previous posts

Link to post
Share on other sites
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...