简体   繁体   中英

PHP file upload: No such file or directory

I've a big problem I'm working on for days now. My file upload in PHP does not work for the following reason.

Here are some parts of my code:

# Upload file1
move_uploaded_file($_FILES['ev_ap_file1']['tmp_name'], 'as-content/'.$_FILES['ev_ap_file1']['name']);
# Upload file2
move_uploaded_file($_FILES['ev_ap_file2']['tmp_name'], 'as-includes/css/'.$_FILES['ev_ap_file2']['name']);

Infos about the files

Array
(
    [ev_ap_file1] => Array
        (
            [name] => test.php
            [type] => application/octet-stream
            [tmp_name] => /tmp/phpfQIobp
            [error] => 0
            [size] => 0
        )

[ev_ap_file2] => Array
    (
        [name] => test.css
        [type] => text/css
        [tmp_name] => /tmp/phpnQqf5T
        [error] => 0
        [size] => 0
    )
)

And finally the error message I get:

Warning: move_uploaded_file(as-content/test.php): failed to open stream: No such file or directory in /var/www/vhosts/steuben-schule.de/httpdocs/steu-admin/action/a_page.php on line 47

Warning: move_uploaded_file(): Unable to move '/tmp/phpfQIobp' to 'as-content/test.php' in /var/www/vhosts/steuben-schule.de/httpdocs/steu-admin/action/a_page.php on line 47

Warning: move_uploaded_file(as-includes/css/test.css): failed to open stream: No such file or directory in /var/www/vhosts/steuben-schule.de/httpdocs/steu-admin/action/a_page.php on line 49

Warning: move_uploaded_file(): Unable to move '/tmp/phpnQqf5T' to 'as-includes/css/test.css' in /var/www/vhosts/steuben-schule.de/httpdocs/steu-admin/action/a_page.php on line 49 Dev Exit enabled.

I already tried a lot of solutions and nothing worked. I'm the owner of the directory and of course it exist.

Thank you for your help! Greetings, Arne

Possible Cases

  • Make sure have folder exist or you have enough permission to create new folder you are trying to move your file.
  • Folder [You want to move] must have write permission.
  • Apache user must have access of /tmp or temporary directory (set in php.ini "tmp_path").
  • Make sure server is not running out of memory`
  • Make sure file is not bigger than max_upload_size parameter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM