Has anyone used PHP's method ftp_put? Because of the type of server I can't do the upload with copy() or move_uploaded_files therefor the ftp_put method seems to be the only 1. Below is the code I have so far; // variables $ftp_server = "<IP>"; $ftp_user_name = "<username>"; $ftp_user_pass = "<password>"; $destination_file = "images/catalogue/".$_FILES['image']['name']; $sourcefile = $_FILES['image']['name']; // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; exit; } else { echo "Connected to $ftp_server, for user $ftp_user_name"; } // upload the file $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); // line 30 // check upload status if (!$upload) { echo "FTP upload has failed!"; } else { echo "Uploaded $source_file to $ftp_server as $destination_file"; } // close the FTP stream ftp_close($conn_id); Code (markup): And I've been getting the following output; I have commented which line is line 30. If anyone can see what the problem is then please let me know. File uploads have been one of my greatest evils this year.
Well I am not sure really what is the purpose of this but I use this code to upload images or other file in my site and it works perfectly.
Thanks edpudol but above I mentioned I couldnt use that function. It's a real pain to be honest. I appreciate your help though
Does it use the ftp put method? If not then it will be using the copy() or move_uploaded_files() method which doesn't work on the server I'm using. Anyone use ftp put? Anyone at all? lol
no never tried it, as i said the above PEAR library does the job, try it first. is it a windows server? u on shared server?
to be honest im out of ideas, i only have/use linux servers (mainly due to cost and i use php not asp.net), try http://uk.php.net/ftp theres a good few replies and sample code, also u might try a php proggie called EzUpload its good for uploading files
i think i've found the problem, you defined your variable as $sourcefile and on line 30 you use it as $source_file that's why the outpost reads the variable is undefined
Thanks for having a look at the code godhand_ez It's certainly a great way to start posting at this forum as well! Weclome to DP mate. I hope it's not your last time here!