Jump to content

This is Complete Crap. Someone Please Help!


Recommended Posts

I have been trying and asking around for days now and nobody seems to be able to come up with something to help me that should be already available. All I want to do is upload a file to my server. I know that people have done it because I have been reading several threads where it is obvious that some people probably succeeded. Of course the problem is that of course nobody likes to post their final result after they have success or they don't post their code when it breaks and they have to update it. Why does it have to be so hard to upload a file? I went through several threads trying out UDFs and various HTTP post methods but I can't get anything to work. After trying for days I was finally like "okay I'll just do it the nasty way and use an html form" but of course when I try to set the value of a file input box in my embedded browser window my script dies with an error: (Browser securuty prevents SetValue of TYPE=FILE)

So now I am back to square 1 with absolutely no method to get a file to my server via HTTP (HTTP is the only option for me). Here are some threads I have tried much code from:

http://www.autoitscript.com/forum/index.php?showtopic=84133

http://www.autoitscript.com/forum/index.php?showtopic=83971

http://www.autoitscript.com/forum/index.php?showtopic=29631

http://www.autoitscript.com/forum/index.php?showtopic=84133

http://www.autoitscript.com/forum/index.php?showtopic=107501

much thanks to anyone who has posting a file worked out and can help.

Link to comment
Share on other sites

Well I see examples of how to do what you need in a couple of them threads.

But I dont see any any example code from you demonstrating what you have tried, in order for someone familiar with those functions to help you with.

So if you stop with the crying onto your keyboard, and do some posting of code, I'm certain you will get some help.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

i have progressed a bit. here is what I have. it seems as though the base64 string gets to the server but then when I save it to a file on the server the jpg is not viewable anymore. i know it is getting there though because the filesize is similar to the one on my desktop. once the string is taken in by my php i am using base64_decode() function and then using fwrite to write the file to disk. still not working.

#include <WinHTTP.au3>
#include <Base64.au3>

Func _POSTRequest($domain, $file, $query, $flags = 0)
    Local $hOpen, $hConnect, $hRequest
    $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6")
    $hConnect = _WinHttpConnect($hOpen, $domain)
    $hRequest = _WinHttpOpenRequest($hConnect, "POST", $file, 'HTTP/1.1', $WINHTTP_NO_REFERER, $WINHTTP_DEFAULT_ACCEPT_TYPES, $flags)
    _WinHttpAddRequestHeaders($hRequest, "Connection: Keep-Alive")
    _WinHttpSendRequest($hRequest, "Content-Type: application/x-www-form-urlencoded", $query)
    _WinHttpReceiveResponse($hRequest)
    Local $aReturn[2]= ['', '']
    If _WinHttpQueryDataAvailable($hRequest) Then
        Do
            $aReturn[1] &= _WinHttpReadData($hRequest)
        Until 0=@extended
    EndIf
    $aReturn[0] = _WinHttpQueryHeaders($hRequest)
    _WinHttpCloseHandle($hRequest)
    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hOpen)

    Return $aReturn ; Array: [0]: headers, [1]: received data.
EndFunc

$fh=FileOpen('hush.jpg', 16)
$image=FileRead($fh)
FileClose($fh)
$str = _Base64Encode($image)

$aReturn = _POSTRequest("www.myserver.info","/upload.php?action=cproc2","filename=test.jpg&file="&$str)
MsgBox(0, '', $aReturn[0] )
MsgBox(0, '', $aReturn[1] )
Edited by Electon
Link to comment
Share on other sites

What is the permission setting on the created file? It should be 644 (rw-r--r--). Now that I think, these permission settings will apply to a file hosted on a *nix server, Windows servers have different requirements, and I don't know what they are.. And what exact error message generates?

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

What is the permission setting on the created file? It should be 644 (rw-r--r--). Now that I think, these permission settings will apply to a file hosted on a *nix server, Windows servers have different requirements, and I don't know what they are.. And what exact error message generates?

no permission error. the directory is 777. the file is being written. the resulting file size looks correct.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...