move_uploaded_file() error on windows with

2019-02-21 09:10发布

Warning: move_uploaded_file(C:\wamp\www/uploads/a.mp3): failed to open stream: No such file or directory in C:\wamp\www\display\uploadfile.php on line 206

Warning: move_uploaded_file(): Unable to move 'C:\wamp\tmp\php75FD.tmp' to 'C:\wamp\www/uploads/a.mp3' in C:\wamp\www\display\uploadfile.php on line 206

var_dump:

array (size=1)
  'file' => 
    array (size=5)
      'name' => string 'a.mp3' (length=5)
      'type' => string 'audio/mp3' (length=9)
      'tmp_name' => string 'C:\wamp\tmp\php75FD.tmp' (length=23)
      'error' => int 0
      'size' => int 4030592

tmp and upload directories have permissions set to everyone > Full Permissions

PHP has upload filesize set correctly

I have no idea why the file wont upload...

Edit: Code: http://pastebin.com/kFG2v2PJ

2条回答
太酷不给撩
2楼-- · 2019-02-21 09:33

Problem: C:\wamp\www/uploads/.

Change your slashes to backslashes and make sure the directory C:\wamp\www\uploads\ exists. You could use the DIRECTORY_SEPARATOR constant to make your code work on multiple systems.

Also, without seeing your code, you need to make sure you're putting the correct paramaters in move_uploaded_file()

Edit after code:

Change

$target_path = APP_PATH."/uploads/";

to

$target_path = APP_PATH . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR;
查看更多
做自己的国王
3楼-- · 2019-02-21 09:37

is your /uploads directory exists? if yes then check var_dump($_FILES) check if $_FILES['uploaded']['error']. contains 0, which means "no error"

查看更多
登录 后发表回答