Hi guys and gals. I am trying to use ftp to upload large files to our hosted server. I have added a few lines to help debug, including hardcoding the file names. I have also tried variations of the file names including forward, backward slashes, double backward slashes.
I am currently stuck checking if a file exists ( this is purely debug code). While the file definitely does exist, and appears in the file list produced by the ftp_rawlist command, the IF statement returns false.
It appears that I am establishing a solid connection to the ftp server as I am able to change directories and return direcotry contents as seen below, but the upload fails. I am testing my upload cod with a small file (484kb) "test.wma". All the upload files will be WMA files.
Any assistance would be aprreciated!
Irvin.
$file = 'C:/Documents and Settings/Irvin/Desktop/test.wma';
$remote_file = 'test.wma';
// set up basic connection
$conn_id = ftp_connect("72.41.84.78");
// login with username and password obatined from previous page
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if (! $login_result) {
die("FTP Login Failed!");
}
// Debug Code
echo "Current directory is: " . ftp_pwd($conn_id) . "<br>";
ftp_chdir($conn_id, "/04_media/files/");
echo "Current directory is: " . ftp_pwd($conn_id) . "<br>";
$buff = ftp_rawlist($conn_id, ftp_pwd($conn_id));
if (!file_exists("/04_media/files/CD1.wma")) {
echo "CD1.wma does not exist!<br>";
}else{
echo "CD1.wma exists!<br>";
}
if (! file_exists("1234.wma")) {
echo "1234.wma does not exist!<br>";
}else{
echo "1234.wma exists!<br>";
}
// End of debug code
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_BINARY)) {
echo "Successfully uploaded $file<br>";
} else {
echo "There was a problem while uploading $file<br>";
}
// close the connection
ftp_close($conn_id);
echo "<pre>";
var_dump($buff);
echo "</pre>";
Current directory is: /
Current directory is: /04_media/files
CD1.wma does not exist!
1234.wma does not exist!
There was a problem while uploading C:/Documents and Settings/Irvin/Desktop/test.wma
array(18) {
[0]=> string(62) "-rw-r--r-- 1 gsgriffi gsgriffi 1688333 Oct 18 02:09 CD1.wma"
[1]=> string(62) "-rw-r--r-- 1 gsgriffi gsgriffi 3145613 Oct 18 02:12 CD2.wma"
[2]=> string(62) "-rw-r--r-- 1 gsgriffi gsgriffi 9695691 Oct 18 02:23 CD3.wma"
[3]=> string(62) "-rw-r--r-- 1 gsgriffi gsgriffi 6079371 Oct 18 02:30 CD4.wma"
[4]=> string(62) "-rw-r--r-- 1 gsgriffi gsgriffi 1712331 Oct 18 02:32 CD5.wma"
...
...