When I try to use ftp_delete() I get the error: Warning: ftp_delete(): File not found. My ftp server should be working fine, I can upload files fine to the same directory without a problem. Here is the PHP:
$fileSource = 'http://localhost/user/images/dfdf.png';
$ftpCon = ftp_connect('localhost');
ftp_login($ftpCon,'---','---');
ftp_delete($ftpCon,$fileSource);
Also when I look at the server logs I can see I get the message: 550 File not found
The url for $fileSource is the file's exact path, I went into localhost and copy/pasted it into the code, still for some reason it can't be found.
The ftp_delete
function acccepts a path to the file. You are providing http://localhost/user/images/dfdf.png
which contains the host ( http://localhost/
). I think you mean to provide /user/images/dfdf.png
, which is just the path.
Example:
ftp_delete($ftpCon, '/user/images/dfdf.png');
When, for example, your FTP root is /user/
, it will mean you need to provide ftp_delete
with /images/dfdf.png
. Thanks to @maremp.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.