|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-05-12 19:19 UTC] fergiboy at home dot com
I created an upload script that will upload to my ftp server, the variable $file comes from a different file:
$a = stripslashes ($file);
$b = basename ($a);
$ftp_server = "ftp_server";
$ftp_user_name = "user";
$ftp_user_pass = "password";
$dir = "ftp";
$conn_id = ftp_connect("$ftp_server");
$login_result = ftp_login($conn_id, "$ftp_user_name", "$ftp_user_pass");
$cd = ftp_chdir ($conn_id, $dir);
$upload = ftp_put($conn_id, $b, $a, FTP_BINARY);
if (!$upload) {
echo "<b>Ftp upload has failed!</b><br>";
} else {
echo "Uploaded<br>";
}
$discon = ftp_quit($conn_id);
echo "<i>$b</i>";
This script will work most of the time, but when the file to be uploaded is located in certain folders the file will not upload.
I made one change to the php.ini file to allow uploads greater than 2 megs.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 14:00:01 2025 UTC |
Hello, can you try if this has anything to do with spaces in filenames? (so try "C:\\Te st.doc"). If that's the case you need to escape your filename like this: $b = strreplace (" ", "\ ", $b);I added an echo $a and an echo $b. I also some debug code to see if it was connection to the ftp server. The output is: C:\Te st.doc Te st.doc Connected Ftp upload has failed! So $a=C:\Te st.doc $b=Te st.doc So it should upload the file as fallows: $upload = ftp_put($conn_id, "C:\Te st.doc", "Te st.doc", FTP_BINARY); I added the code: $b = str_replace (" ", "\ ", $b); to no avail :(