简体   繁体   English

如果我使用ftp_put将文件上传到ftp服务器,如何获取上传文件的完整url?

[英]If I used ftp_put to upload a file to an ftp server, how would I get the full url of the uploaded file?

For example, I use file_put() to upload file.rar to public_html/rar/ . 例如,我使用file_put()file.rar上传到public_html/rar/ Would it be possible for me to get the web address of that .rar file? 我可以获取该.rar文件的网址吗?

You'd have to know that ftp path /public_html/ is the document root for the website. 您必须知道ftp路径/ public_html /是网站的文档根目录。 Once you know that, you can just strip the FTP path down. 知道这一点后,您就可以剥离FTP路径。

You can obviously do this for particular sites, but there's no real way to automatically determine the document root, so this can't be done automatically without asking the user where the document root is. 您显然可以对特定站点执行此操作,但是没有自动确定文档根目录的真正方法,因此,如果不询问用户文档根目录在哪里,就无法自动完成。

(I guess you could try to guess based on common paths like 'public_html' or 'www' or 'content', but you'd only be guessing and could be wrong) (我猜您可以尝试根据常见路径(例如“ public_html”或“ www”或“ content”)进行猜测,但您只会在猜测,可能是错误的)

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

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