Sign in to follow this  
Followers 0
autoititaly

send files to server with method post

25 posts in this topic

Hello everyone!

excuse my English, I'm Italian ...

can you tell me how to load a file onto their own web space with the post method?

in short, send a file on my web space via http .... who gives me a hand? I send a picture but I can not use ftp ... I would use php on my web host and autoit on my pc ...

Share this post


Link to post
Share on other sites



nobody knows how I can send a photo using the http?

Share this post


Link to post
Share on other sites

Easy way of sending a file to a web host is using FTP..

If you are having problems in sending files using FTP, then post your code here.

Share this post


Link to post
Share on other sites

I do not have to use the FTP protocol ... I would use the http protocol.

I can not use the FTP protocol ... you can use the HTTP protocol to send an image to a own web space?

Share this post


Link to post
Share on other sites

I don't know how to use the HTTP protocol to send an image to a own web space..

Share this post


Link to post
Share on other sites

Show php code.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

I do not have the php code ... I know II have to use the method post php , I would have thought to open the image in binary mode and read it and send it to the php script that writes to a file and rename it in seconds ... jpg your reasoning is right?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I do not have the php code ... I know II have to use the method post php , I would have thought to open the image in binary mode and read it and send it to the php script that writes to a file and rename it in seconds ... jpg your reasoning is right?

In post you have both PHP and AutoIt code. It's an example of uploading more than one file at time. Could have been anything else though.

On server side you run PHP and in this case it will just print some upload data. In some real situation it would save files to desired location.

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

you mean these two?

<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
      <title>Multiple files upload</title>
  </head>
  <body>
        <h1>Multiupload</h1>
        <form action="" method="post" enctype="multipart/form-data">
                <input type="file" name="files[]" multiple="multiple" />
                <input type="submit" />
        </form>

        <pre>
                <?php
                        print_r($_FILES);
                ?>
        </pre>
  </body>
</html>

#include "WinHttp.au3"
Opt("MustDeclareVars", 1)

Global $hOpen, $hConnect
Global $sRead, $hFileHTM, $sFileHTM = @ScriptDir & "\Form.htm"

; Initialize and get session handle
$hOpen = _WinHttpOpen()
; Get connection handle
$hConnect = _WinHttpConnect($hOpen, "your.server.here") ; <- your server here
; Fill form on this page
$sRead = _WinHttpSimpleFormFill($hConnect, "test.php", "index:0", "name:files[]", "PHP#50338:" & @ScriptFullPath & "|" & @ScriptFullPath & "|" & @ScriptFullPath)
; Close connection handle
_WinHttpCloseHandle($hConnect)
; Close session handle
_WinHttpCloseHandle($hOpen)

ConsoleWrite($sRead & @CRLF)

If $sRead Then
    MsgBox(64 + 262144, "Done!", "Will open returned page in your default browser now." & @CRLF & _
            "It should show array of uploaded files below the form.")
    $hFileHTM = FileOpen($sFileHTM, 2)
    FileWrite($hFileHTM, $sRead)
    FileClose($hFileHTM)
    ShellExecuteWait($sFileHTM)
EndIf

if these two could tell me where to download the udf ... and that changes should be made to load a jpg file?

limited in size? if I load the entire contents of a folder such as a zip file, picture you can?

Edited by autoititaly

Share this post


Link to post
Share on other sites

Picture you can, zip file even.

May the Force be with you.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I tried the script but did not charge me anything on my web space ...I downloaded the udf and put them in the same folder as the script...but on my web space I find myself not posted any photos like that?

Edited by autoititaly

Share this post


Link to post
Share on other sites

I also tried that but it don't seems to work, someone can help?

Share this post


Link to post
Share on other sites

I also tried that but it don't seems to work, someone can help?

Presumably you didn't use exactly the code that trancexx showed?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I used the same code:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "F:\WinHttp\Example.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams

+>12:28:11 Starting AutoIt3Wrapper v.2.0.1.24 Environment(Language:0409 Keyboard:00000409 OS:WIN_XP/Service Pack 3 CPU:X86 OS:X86)

>Running AU3Check (1.54.19.0) from:C:\Program Files\AutoIt3

+>12:28:11 AU3Check ended.rc:0

>Running:(3.3.6.1):C:\Program Files\AutoIt3\autoit3.exe "F:\WinHttp\Example.au3"

+>12:28:16 AutoIT3.exe ended.rc:0

>Exit code: 0 Time: 6.740

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

The output shows no error. If you do not want to use _WinHttpFormFill, you have to create the POST-data manually:

$sBoundary = "--------WinHTTPMultiPaRtEXAMPLE"
$sHeaders = "Content-Type: multipart/form-data; boundary=" & $sBoundary & @CRLF

$sData = ''
$sData &= "--" & $sBoundary & @CRLF
$sData &= 'Content-Disposition: form-data; name="fieldname"' & @CRLF & @CRLF & "someValue" & @CRLF
$sData &= "--" & $sBoundary & @CRLF
$sData &= __WinHttpFileContent("", "fileupload", "C:\file.txt")
$sData &= "--" & $sBoundary & "--" & @CRLF

_WinHttpSimpleRequest($hConnect, "POST", "/form.php", Default, StringToBinary($sData,0), $sHeaders)
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

could you please post an example of a working script?

Edited by autoititaly

Share this post


Link to post
Share on other sites

What do you get when you run this code?

#include "WinHttp.au3"
Opt("MustDeclareVars", 1)

Global $hOpen, $hConnect
Global $sRead, $hFileHTM, $sFileHTM = @ScriptDir & "\Form.htm"

; Initialize and get session handle
$hOpen = _WinHttpOpen()
; Get connection handle
$hConnect = _WinHttpConnect($hOpen, "dikydee.dyndns.org")
; Fill form on this page
$sRead = _WinHttpSimpleFormFill($hConnect, "test.php", "index:0", "name:files[]", "PHP#50338:" & @ScriptFullPath & "|" & @ScriptFullPath & "|" & @ScriptFullPath)
; Close connection handle
_WinHttpCloseHandle($hConnect)
; Close session handle
_WinHttpCloseHandle($hOpen)

ConsoleWrite($sRead & @CRLF)

If $sRead Then
    MsgBox(64 + 262144, "Done!", "Will open returned page in your default browser now." & @CRLF & _
            "It should show array of uploaded files below the form.")
    $hFileHTM = FileOpen($sFileHTM, 2)
    FileWrite($hFileHTM, $sRead)
    FileClose($hFileHTM)
    ShellExecuteWait($sFileHTM)
EndIf

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#include "WinHttp.au3"
Opt("MustDeclareVars", 1)

Global $hOpen, $hConnect
Global $sRead, $hFileHTM, $sFileHTM = @ScriptDir & "\form.htm"
$sBoundary = "--------WinHTTPMultiPaRtEXAMPLE"
$sHeaders = "Content-Type: multipart/form-data; boundary=" & $sBoundary & @CRLF
$sData = ''
$sData &= "--" & $sBoundary & @CRLF
$sData &= 'Content-Disposition: form-data; name="fieldname"' & @CRLF & @CRLF & "someValue" & @CRLF
$sData &= "--" & $sBoundary & @CRLF
$sData &= __WinHttpFileContent("", "fileupload", "C:\file.txt")
$sData &= "--" & $sBoundary & "--" & @CRLF


; Initialize and get session handle
$hOpen = _WinHttpOpen()
; Get connection handle
$hConnect = _WinHttpConnect($hOpen, "website.net") ; <- your server here
; Fill form on this page
_WinHttpSimpleRequest($hConnect, "POST", "/default.php", Default, StringToBinary($sData,0), $sHeaders)
; Close connection handle
_WinHttpCloseHandle($hConnect)
; Close session handle
_WinHttpCloseHandle($hOpen)

ConsoleWrite($sRead & @CRLF)
If $sRead Then
    MsgBox(64 + 262144, "Done!", "Will open returned page in your default browser now." & @CRLF & _
            "It should show array of uploaded files below the form.")
    $hFileHTM = FileOpen($sFileHTM, 2)
    FileWrite($hFileHTM, $sRead)
    FileClose($hFileHTM)
    ShellExecuteWait($sFileHTM)
EndIf

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\stefano\Desktop\upload\client.au3"    
C:\Users\utente\Desktop\upload\client.au3 (6) : ==> Variable used without being declared.:
$sBoundary = "--------WinHTTPMultiPaRtEXAMPLE"
^ ERROR
>Exit code: 1    Time: 0.660

I tried so but I get the following error...

Who can help me please?

Share this post


Link to post
Share on other sites

What do you get when you run this code?

#include "WinHttp.au3"
Opt("MustDeclareVars", 1)

Global $hOpen, $hConnect
Global $sRead, $hFileHTM, $sFileHTM = @ScriptDir & "\Form.htm"

; Initialize and get session handle
$hOpen = _WinHttpOpen()
; Get connection handle
$hConnect = _WinHttpConnect($hOpen, "dikydee.dyndns.org")
; Fill form on this page
$sRead = _WinHttpSimpleFormFill($hConnect, "test.php", "index:0", "name:files[]", "PHP#50338:" & @ScriptFullPath & "|" & @ScriptFullPath & "|" & @ScriptFullPath)
; Close connection handle
_WinHttpCloseHandle($hConnect)
; Close session handle
_WinHttpCloseHandle($hOpen)

ConsoleWrite($sRead & @CRLF)

If $sRead Then
    MsgBox(64 + 262144, "Done!", "Will open returned page in your default browser now." & @CRLF & _
            "It should show array of uploaded files below the form.")
    $hFileHTM = FileOpen($sFileHTM, 2)
    FileWrite($hFileHTM, $sRead)
    FileClose($hFileHTM)
    ShellExecuteWait($sFileHTM)
EndIf

I tried the code but I did not find any file on my host ...

Share this post


Link to post
Share on other sites

I tried the code but I did not find any file on my host ...

Find some other thing than programming to play with. Shiny marbles maybe.

♡♡♡

.

eMyvnE

Share this post


Link to post
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
Sign in to follow this  
Followers 0