Sign in to follow this  
Followers 0
EmptySpace

How to upload file to my host with _winhttp

21 posts in this topic

Im newbie in php/site things so I found it difficult to do that.

O use 000webhost.com free hosting.

My code looks something like this:

#include <WinHttp.au3>                   
Global Const $sAddress = "make-cash-now.net76.net" ;random name..
$subdomain = "public_html/upload.php"
$upload = (@scriptdir & "\test.htm")
Global $hOpen = _WinHttpOpen()
Global $hConnect = _WinHttpConnect($hOpen, $sAddress)
Global $sHTM = _WinHttpSimpleFormFill($hConnect, $subdomain, Default, "name:ufile", $upload)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

For one guy this works. Maybe problem is that I use free hosting?

File upload details from host: FTP host name make-cash-now.net76.net FTP user name a6677825 FTP password ****** File system path /home/a6677828 Folder to upload files public_html

Website IP address 31.170.160.78 Server name server14.000webhost.com

I really need to make it to work.

Share this post


Link to post
Share on other sites



Why don't you use FTPEx functions?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Jos, one guy said that it works but he didnt said how it works. He said that http + php is hard to hack. But I only need fast way to upload text files. Faster than using smpt mailer. Php script rename file and put it into uploads folder. I forgot that there is FTPex functions. I guess its faster than using smpt to send/receive things.

Edited by EdgarT

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Cant make script whitch would upload any file.

#include
Global $FILE = "C:Documents and Settings8888Desktop****demo.txt"
$filename = "/test.txt"

$host = "make-cash-now.net76.net" ; Hostname of the webserver (Can be a domain name or an IP)
$user = "a6677826" ; FTP Username
$pass = "pass" ; FTP Password
$public = "/public_html/" ; If you dont have a /public_html/ leave this as blank ("")
$folder = "uploads/" ; This is the folder where your files will upload to

$open = _FTP_Open("Upload")

If $open Then
$conn = _FTP_Connect($open, $host, $user, $pass, 0, 21)

If $conn Then
$ftpp = _FTP_FilePut($conn, $file, $public & $folder & $filename)

If $ftpp Then
_FTP_Close($open)
EndIf
EndIf
EndIf
Edited by EdgarT

Share this post


Link to post
Share on other sites

That's not a whole lot of information. What's not working, where is it failing?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Cant make script whitch would upload any file.

$filename = "/test.txt"
$public = "/public_html/" ; If you dont have a /public_html/ leave this as blank ("")
$folder = "uploads/" ; This is the folder where your files will upload to
$ftpp = _FTP_FilePut($conn, $file, $public & $folder & $filename)

Is the target file name correct?

"/public_html/uploads//test.txt"

Other than that: You indeed need to provide information which means much much more details than "it doesn't work".

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I click f5 to start script. It works fine but I dont find file in my host. No errors or something so I thought that I wrote incorrectly. Maybe host or smthg.

Share this post


Link to post
Share on other sites

Try adding some error checking in there, you start the script and if there's any errors, you'll never know it because you don't check for them.

For example, what's the return from _FTP_Open, or from _FTP_Connect, or even from _FTP_FilePut? Without know WHERE it failed, you will never know why it failed.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

_FTP_Open returns error

Share this post


Link to post
Share on other sites

I cant see way how to fix it.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I am sure my dentist is jealous ....

I cant see way how to fix it.

So, when it it going to dawn to you that we need more than "it doesn't work"?

What is the returned Error code and have you search on it?

Edited by Jos
1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

#include
Global $FILE = "C:Documents and Settings8888Desktop****demo.txt"
;$filename = "test.txt"

$host = "make-cash-now.net76.net" ; Hostname of the webserver (Can be a domain name or an IP)
$user = "a6677828" ; FTP Username
$pass = "pass" ; FTP Password
;$public = "/public_html/" ; If you dont have a /public_html/ leave this as blank ("")
;$folder = "uploads/" ; This is the folder where your files will upload to

Global $open = _FTP_Open('MyFTP Control')
ConsoleWrite(@error & "-" & @extended & @CRLF)
If $open Then
$conn = _FTP_Connect($open, $host, $user, $pass, 0, 21)
ConsoleWrite(@error & "-" & @extended & @CRLF)
If $conn Then
$ftpp = _FTP_FilePut($conn, $file, "public_html/uploads/test.txt")
ConsoleWrite(@error & "-" & @extended & @CRLF)
If $ftpp Then
_FTP_Close($open)
EndIf
EndIf
EndIf

And got

0-0

-1-0

into console. I know only that _FTP_Open() wont work. I dont know how to get more info

(or maybe _FTP_Connect() fault? )

Edited by EdgarT

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Your open is working, the error value is zero. Your connect isn't working. What happens if you ping the host, does it respond?

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Have you tried to login with a regular FTP client like Filezilla to ensure you have the correct Host, Username and password?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I login with web based client. Ill try with filezilla.

Share this post


Link to post
Share on other sites

EdgarT,

Sure this is you server name?

[color="#5a5a5a"]$host[/color] [color="#ff8000"]=[/color] [color="#ff0000"]"make-cash-now.net76.net"[/color] [i][color="#008000"]; Hostname of the webserver (Can be a domain name or an IP)[/color][/i]

Or is this your server name?

Server name server14.000webhost.com

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

FTP details from 000webhost :

FTP host name make-cash-now.net76.net

I tried everything but cant login from filezilla. Maybe something wrong with that free host?

Edit: I tried other hosting and no errors but it uploads nothing.

Edited by EdgarT

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