简体   繁体   English

PHP ftp_delete找不到文件

[英]PHP ftp_delete can't find file

When I try to use ftp_delete() I get the error: Warning: ftp_delete(): File not found. 当我尝试使用ftp_delete()时,出现错误:警告:ftp_delete():找不到文件。 My ftp server should be working fine, I can upload files fine to the same directory without a problem. 我的ftp服务器应该工作正常,我可以将文件正常上传到同一目录,而不会出现问题。 Here is the PHP: 这是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 另外,当我查看服务器日志时,我可以看到消息: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. $ fileSource的url是文件的确切路径,我进入localhost并将其复制/粘贴到代码中,但由于某种原因仍找不到它。

The ftp_delete function acccepts a path to the file. ftp_delete函数接受文件的路径。 You are providing http://localhost/user/images/dfdf.png which contains the host ( http://localhost/ ). 您正在提供包含主机( http://localhost/ )的http://localhost/user/images/dfdf.png I think you mean to provide /user/images/dfdf.png , which is just the path. 我认为您的意思是提供/user/images/dfdf.png ,这只是路径。

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 . 例如,当您的FTP根目录为/user/ ,这意味着您需要为ftp_delete提供/images/dfdf.png Thanks to @maremp. 感谢@maremp。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM