我目前正在Joomla!网站。我正在使用Jumi扩展(它允许在Joomla!自己内部创建和执行自定义脚本)创建一个简单的文件上传工具。问题是,我得到以下错误:PHP图像上传麻烦
警告:副本(C:/xampp/htdocs/images/1253889508.jpg)[function.copy]:未能打开流:在没有这样的文件或目录C:\ XAMPP \ htdocs中\的Joomla \部件\ com_jumi \ jumi.php(25):行的eval()'d代码
违规代码如下:
//we will give an unique name, for example the time in unix time format
$image_name=time().'.'.$extension;
//the new name will be containing the full path where will be stored (images folder)
$newname='C:/xampp/htdocs/images/'.$image_name;
//we verify if the image has been uploaded, and print error instead
$copied = copy($_FILES['image']['tmp_name'], $newname);
完整代码可用here。一旦我得到这个工作,我会修改它,以满足我的网站的需求。
我不确定问题是否与Jumi有关的权限问题或是否存在其他问题。我能说的最好的是,无论什么原因,临时文件都没有被创建。
感谢您的任何提示,你可能有!
copy()确实是错误的方法,因为文件必须从临时目录中移出。 move_uploaded_file()以做一个副本从TMP目录 – NDM 2009-09-25 14:48:44
我想说move_uploaded_file是更明智的选择,因为它显然是为了准确地解决这个问题,但它是你的代码:) – inkedmn 2009-09-25 14:56:34
即使副本()现在工作,是它更好地尝试move_uploaded_file?另外,如果目录位于特定位置,我该如何使用相对路径? – 2009-09-25 14:57:06