2010-11-20 04:49



I'm trying to upload a file using PHP. My HTML page with the form is stored at


PHP page is


and the file I'm trying to upload is


When I try to upload the file, I get the following error:

Warning: move_uploaded_file(/uploads/openoffice.txt) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp\www\myproject\upload.php on line 40

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\wamp\tmp\phpF66A.tmp' to '/uploads/openoffice.txt' in C:\wamp\www\myproject\upload.php on line 40 Problem: could not move file to destination directory

Here are lines 40-43 of upload.php:

if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $upfile)) {
    echo 'Problem: could not move file to destination directory';

The fact that it's looking in upload.php instead of the folder that it's in makes me wonder whether it's a server error or an issue with my PHP.

I Googled and got this advice but I don't know if it's the right advice, or how to implement it. Help?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongshijiao6890 dongshijiao6890 11年前

    You should be supplying a file system path for $upFile, not a web based path. try using the full system path to you your uploads directory like C:\path\to\uploads\openoffice.txt. Unless of course youre actually trying to place the file in C:\uploads...

    点赞 评论 复制链接分享
  • duankekan9269 duankekan9269 11年前

    Give your '/uploads/' folder where you are going to upload your file. 777 rights. Give full permission to that directory.

    点赞 评论 复制链接分享
  • dqellle310167 dqellle310167 7年前

    Try this code

    $imgName = time();
    $imgPath = BASEPATH."../uploads/".$imgName;
    $image = base_url().'uploads/'.$imgName;
    $imageNew =$imgName;

    Where uploads is the folder name just rename it with your folder name or make your folder as name it as uploads. Its working code.


    点赞 评论 复制链接分享