Showing results for 
Search instead for 
Did you mean: 

Ftp upload failure in php script.


Ftp upload failure in php script.

I am trying to write a script which will effect transfer of an image from my home machine to my webspace, ie a homemade job equivalent to what (say) WS_FTP does. The reason is that I want to provide a facility for others to upload a photograph (without revealing my password).

I have succeeded insofar as I have written two pages, one to use a form to access the file and its details on my home disc, and the other to respond to the form by transferring the file from its current location to the webspace.

The upload script is as follows:

$jim = move_uploaded_file($HTTP_POST_FILES["file"]["tmp_name"],'');
echo $jim;

(For security reasons "password" has been substituted for my real one!)

I have done this procedure first on the Apache server on my home machine. The file is copied successfully from its original location to a new one specified in the second argument in move_uploaded_file (c:\fred.jpg). The problems arises on transferring the script to my cgi space so that it may be used publicly.

All works right through connection to the webspace, and fred.jpg appears afterwards in the file directory (on access by WS_FTP). The script itself produces two error messages on execution, however, and the uploaded file is recorded as having content 0 bites on the webspace.

The error messages are (with my password amended, again, for security reasons):

Warning: move_uploaded_file( failed to open stream: FTP server reports 229 Entering Extended Passive Mode (|||4844|) in /files/home2/meikleriggs1/temp/upload.php on line 15

Warning: move_uploaded_file(): Unable to move '/var/tmp/phpxp5Fcx' to '' in /files/home2/meikleriggs1/temp/upload.php on line 15

Can anyone advise on what further is required here, please!

Ftp upload failure in php script.

I am replying to myself.

I was sure that the problem was at the stage of transfer of the uploaded file from its temporary location on the CGI server to the designated place. This must be so since, as I have subsequently discovered, the whole procedure works if I use a different target server.

I changed the ftp part to aim at the Totalserve webserver. I have an old account with them, and have noticed that surprisingly it accepts ftp uploads even on a Free-online connection. Ergo it was worth trying the procedure there.

This points to a problem with the way the servers are set up at Free-online: it is does not seem possible to load a file onto the webserver from the CGI server by ftp.

Ftp upload failure in php script.

From Servers: CGI/Shell Server Basics
An attempt to log on to any Free-Online server will succeed only if your Internet connection has been established through Free-Online or one of the other PlusNet ISPs.

I have managed to get uploading via the webserver working using shop front end software, but i dont think it uses the ftp cmd, i never looked the the code in oscommerce but its open source tho

i did have to change the permissons on my images folder to everyone write access for it to work, this gets a round uploading from a differant isp, but this is NOT SECURE, to make it more secure you would have to chown the folder images to wwwuser as the owner of the folder images and the group to ur login name then just give write access on owner and group, but i am still trying to figure out why it wont let me chown the folder to wwwuser.

hope this info helps