【问题标题】:move_uploaded_file php function is not workingmove_uploaded_file php 函数不起作用
【发布时间】:2016-12-14 02:54:31
【问题描述】:

我很清楚,类似的问题在这个网站上得到了多次回答。我google并搜索了很多论坛bt我无法解决问题。

move_uploaded_file函数不工作,由于路径合适,该函数无法上传文件。

这是我的代码

$targetPath = "/home/abc/public_html/uploads/";

        let my website is abc.com

        move_uploaded_file($_FILES['Filedata']['tmp_name'],$targetPath.$_FILES['Filedata']['name']);
  • 我必须上传文件到/public_html/uploads/downloads
  • move_uploaded_file 函数在 /public_html/assets/uploadify
  • 输入表单在 /public_html/application/modules/downloads/views/admin位置

注意:此代码在我的本地主机中运行良好

任何人都可以建议路径

请不要重复标记

【问题讨论】:

  • 您是否尝试过将完整路径放入目录? public_html 在哪里?您可能需要该目录的完整服务器路径 - 例如/var/www/public_html
  • 你检查过文件权限吗?
  • 是的,我给了downloads文件夹0777权限
  • $targetPath = "../../../../../uploads/"; 试试这个目录。
  • @JeesKDenny 不,同样的结果

标签: php file-upload image-upload


【解决方案1】:

假设你的上传文件在public_html目录下,把$targetPath改成/uploads/并改

move_uploaded_file($_FILES['Filedata']['tmp_name'],"$targetPath".$_FILES['Filedata']['name']);

这对我有用。

【讨论】:

  • $targetPath添加引号
  • 我直接使用"/uploads/".$_FILES['Filedata']['name']
  • 另外,请检查您是否使用了正确的<input type="file" name="Filedata" >
  • 或者,如果这些都不起作用,请使用http://example.com/uploads/"
  • 我的编码在本地工作,接下来我按照你说的尝试http://example.com/uploads/
猜你喜欢
  • 2020-11-04
  • 2013-09-26
  • 1970-01-01
  • 2019-04-09
  • 2016-10-01
  • 2018-07-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多