File function with ftp
-
Hi there, I am trying to check that if the file is already there in a folder of ftp or not with following: file_exists("ftp://ftpUserName:ftpPassword@ftpAddress/ftpUploadFolder/folderName/fileName.doc") but I can not get the result and the same for 'filesize()' function. If you know the way then please tell me. Thank you in Advance.:)
-------------------------------------------------------------------------------------------------- Hiral Shah India If you think that my question is good enough and can be helpful for other then don't forget to vote. :)
-
Hi there, I am trying to check that if the file is already there in a folder of ftp or not with following: file_exists("ftp://ftpUserName:ftpPassword@ftpAddress/ftpUploadFolder/folderName/fileName.doc") but I can not get the result and the same for 'filesize()' function. If you know the way then please tell me. Thank you in Advance.:)
-------------------------------------------------------------------------------------------------- Hiral Shah India If you think that my question is good enough and can be helpful for other then don't forget to vote. :)
Those functions mainly will only work on the local file system. You can use the:
is_readable('LOCATION');
function which should work for FTP but other than that you may need to use the PHP functions to determine the size.
Brad Australian - Captain See Sharp on "Religion" any half intelligent person can come to the conclusion that pink unicorns do not exist.
-
Those functions mainly will only work on the local file system. You can use the:
is_readable('LOCATION');
function which should work for FTP but other than that you may need to use the PHP functions to determine the size.
Brad Australian - Captain See Sharp on "Religion" any half intelligent person can come to the conclusion that pink unicorns do not exist.
I wrote following code in php : $uploadDir = "ftp://$ftpUserName:$ftpPassword@$ftpAddress/$ftpUploadFolder/$folderName/$fileName"; if(is_readable($uploadDir)) $msg = "$fileName is already exist. Your File is Not Uploaded"; else $msg = "File Uploaded"; I am uploading a file that is already exist yet it is showing me the secons message that is "File Uploaded"
-------------------------------------------------------------------------------------------------- Hiral Shah India If you think that my question is good enough and can be helpful for other then don't forget to vote. :)
-
I wrote following code in php : $uploadDir = "ftp://$ftpUserName:$ftpPassword@$ftpAddress/$ftpUploadFolder/$folderName/$fileName"; if(is_readable($uploadDir)) $msg = "$fileName is already exist. Your File is Not Uploaded"; else $msg = "File Uploaded"; I am uploading a file that is already exist yet it is showing me the secons message that is "File Uploaded"
-------------------------------------------------------------------------------------------------- Hiral Shah India If you think that my question is good enough and can be helpful for other then don't forget to vote. :)
-
Those functions mainly will only work on the local file system. You can use the:
is_readable('LOCATION');
function which should work for FTP but other than that you may need to use the PHP functions to determine the size.
Brad Australian - Captain See Sharp on "Religion" any half intelligent person can come to the conclusion that pink unicorns do not exist.
Even I used is_file("fileName") function too but the result is not proper.
-------------------------------------------------------------------------------------------------- Hiral Shah India If you think that my question is good enough and can be helpful for other then don't forget to vote. :)
-
Even I used is_file("fileName") function too but the result is not proper.
-------------------------------------------------------------------------------------------------- Hiral Shah India If you think that my question is good enough and can be helpful for other then don't forget to vote. :)
Ok here is what a quick toss around of ideas in my head brought up:
//Connect to the FTP server
//$con = the FTP connection
//$fileName = the requested file name$fileList = ftp_nlist($con, "/upload/Directory/etc");
if(in_array($fileName, $fileList)){
echo 'File already exists!';
exit();
}Last modified: after originally posted --
Brad Australian - Bradml on "MVP Status" If this was posted in a programming board please rate my answer