robinbarton posted on 2009-05-26 03:27:08 #
I have a standard file uploader with a form in HTML which passes a file to a PHP script. I can successfully test for the file that is being passed.
My ftp_put statement fails, however, because it can't find that file. I know because I hard-coded another filename (php.ini) and it put that into the destination location just fine.
I think the problem is either that it doesn't know where to look for my local file or the local file isn't REALLY anywhere.
The pertinent code is:
$UploadedFilename = $_FILES['VideoLocation']['name'];
//THIS WORKS IF I ECHO IT, SO IT (SOMETHING) IS COMING FROM THE HTML FORM
$upload = ftp_put($conn_id, $TargetFilename, $_FILES['VideoLocation']['name'], FTP_BINARY);
//THIS WORKS IF I CHANGE $_FILES['VideoLocation']['name'] TO "php.ini"
The most popular forum posts:
Comments / discussions
Olaf posted on 2009-05-26 04:59:40 #
Hi,
The PHP ftp functions are not a great choice.
Maybe you like to try an upload using curl?:
http://www.web-development-blog.com/archives/tutorial-ftp-upload-via-curl/
robinbarton posted on 2009-05-26 16:36:56 #
Thank you, I checked out cURL, although that didn't work for me either. My server has PHP 2.x, so it's creating many issues. HOWEVER, you still helped me because this article had the first example of $_FILES['upload']['tmp_name']. I wasn't sure what tmp_name was supposed to be, so I echoed it and saw that, sure enough, I had one. THIS was the variable I was looking for!
Once I changed my code to
$upload = ftp_put($conn_id, $TargetFilename,$_FILES['upload']['tmp_name'], FTP_BINARY);
it worked!
I also found another workaround to a topic posted on your boards.
You know how file_exists() doesn't work in older versions of PHP?
I figured that all I need to do to verify whether or not my file was FTP'd successfully or not was to try and chmod 777 it. If that command received an error, the file might not be there. In any case, I know the file IS there if chmod is successful.
Thanks for your help,
A brand new PHP user!
Olaf posted on 2009-05-26 18:25:22 #
great that the tutorial has helped to solve your problem.
If you say that you are php newbie, you should start with php5, it makes no sense to learn old code.
btw. I'm surprised that the $_FILES array works for you I thought that array type was added in later php versions.
(the array was called $HTTP_POST_FILES['yourUpload'] before)