dp5657087 2009-09-25 14:43
浏览 28
已采纳

PHP图片上传麻烦

I am currently working on a Joomla! website. I am using the Jumi extension (which allows custom scripts to be made and executed within Joomla! itself) to create a simple file upload tool. The problem is that I get the following error:

Warning: copy(C:/xampp/htdocs/images/1253889508.jpg) [function.copy]: failed to open stream: No such file or directory in C:\xampp\htdocs\Joomla\components\com_jumi\jumi.php(25) : eval()'d code on line 61

The offending code is as follows:

//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);

The full code is available here. Once I get this working, I will be modifying it to meet the needs of my website.

I'm not sure if the problem is a permissions issue with Jumi or if there is some other problem. The best I can tell is that for whatever reason, the temp file is not being created.

Thanks for any tips you may have!

  • 写回答

3条回答 默认 最新

  • douxing5598 2009-09-25 14:47
    关注

    Try this:

    if(move_uploaded_file($_FILES['image']['tmp_name'], $newname)){
        // move worked, carry on
    }
    

    And use relative paths instead of absolute ones.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog