Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to test out an http image upload function in PHP. I've tried this on Apache on both OSX (locally) and Ubuntu (remotely).

In php.ini I set upload_tmp_dir = /var/tmp/http-upload. Both tmp and http-upload have permissions set to drwxrwxrwt.

Every time I try uploading I get an error that the file does not exist in the temporary location.

Am I missing anything in my configuration?

The actual upload function is:

    if ($_FILES) {
        $target_path = '/assets/logos' . basename($_FILES['logo']['name']);
    if (move_uploaded_file($_FILES['logo']['tmp_name'], $target_path)) {
        echo 'success';
    else {
        echo 'fail';

And the specific error:

Warning: move_uploaded_file(/logos/1317156765-shinetsu.gif): failed to open stream: No such file or directory in upload.php on line 8 Warning: move_uploaded_file(): Unable to move '/tmp/http-upload/php8CNWja' to '/logos/1317156765-shinetsu.gif' in upload.php on line 8 fail
share|improve this question
up vote 1 down vote accepted

I suspect its trying to move your uploaded files to /assets/logos, vs /var. You may want to try using ./assets/logos, or getting the base dir for your site somehow.

share|improve this answer
I tried commenting out the move part completely and doesn't seem to be uploading to the tmp/http-upload directory at all. – Choy Oct 21 '12 at 17:56
I don't know why it didn't show up in the tmp directory when I was testing with the move_uploaded_file() commented out, but I just tried again this time specifying the $_SERVER['DOCUMENT_ROOT'] and leaving the move_uploaded_file() function intact and it worked on both! Thanks for your help. – Choy Oct 21 '12 at 18:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.