Hi, I'm trying to upload a pdf file from a local drive to the server using a
php routine. I've done it server to server before with no issues but this
just keeps failing on me.
This is the function I'm calling, it connects and logs in just fine, but it
will not upload the file. The file I'm sending is just a 100k pdf file. I
have php set up with:
max_execution_time = 30
max_input_time = 60
memory_limit = 20M
file_uploads = On
upload_max_filesize = 8M
ftpData($fileField, "/var/www/html/Docs/DU/DU1.pdf")
with $filefield just being a local path taken from a filebrowser in a html
form. I've also tried using ftp_chdir to change the destination path and
when calling ftp_pwd is shows the current directory has changed to the
correct one but it still won't write anything down.
any ideas?
James
function ftpData($Source, $Dest){
// set up basic connection
$success = 1;
$ftp_server = "blahblahbla.com";
$ftp_user_name = "dummy";
$ftp_user_pass = "dammy";
$destination_file = $Dest;
$source_file = $Source;
$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!<br>";
echo "Attempted to connect to $ftp_server for user
$ftp_user_name<br>";
$success = 0;
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name<br>";
}
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// check upload status
if (!$upload) {
echo "FTP upload has failed!<br>";
$success = 0;
} else {
echo "Uploaded $source_file to $ftp_server as
$destination_file<br>";
}
// close the FTP stream
ftp_close($conn_id);
return($success);
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php