Page 1 of 2

cant get file upload to work on localhost

Posted: Wed Nov 28, 2007 6:02 pm
by Luke
i swear... configuration problems are the most frustrating thing in the world. I could punch a kitten right now. anyway... I cannot get file uploads to work on my local machine. I have my upload_tmp_dir set to "C:\tmp\uploads". I upload a file, and it says in the $_FILES array that there is now a file available at "C:\tmp\uploads\php86.tmp" but then I go to the directory and it isn't there. so I changed the upload_tmp_dir to C:\PHP\tmp and still I get nothing, and yet every time I do an upload, it says there is now a file available in $_FILES['file']['tmp_name']. also move_uploaded_file doesn't work (of course).

Posted: Wed Nov 28, 2007 6:04 pm
by ianhull
Is the directory writeable?

chmod?

Posted: Wed Nov 28, 2007 6:05 pm
by Luke
I'm on windows

Posted: Wed Nov 28, 2007 6:09 pm
by ianhull
server 2003?

I found that when installing php5 on s2k3 i had some teething problems, I then tried the installer which totally failed.

I then follwed some new instructions, did not realise that I had two php.ini files one in C:/php and 1 oin C:/WINDOWS

have you checked you are using the correct .ini too?

just a thought.

Posted: Wed Nov 28, 2007 6:12 pm
by Luke
yep it's the right one :(

Posted: Wed Nov 28, 2007 6:20 pm
by ianhull
Are you uploading a picture? .jpg, or .gif?

If you are maybe you could try outputting it using image straight from the

Code: Select all

$_FILES['file']['tmp_name'];
Seems strange does this one :cry:

Posted: Wed Nov 28, 2007 6:25 pm
by Luke
here is the output of a var_dump($_FILES);

Code: Select all

array(1) {
  ["data"]=>
  array(5) {
    ["name"]=>
    array(1) {
      ["Import"]=>
      array(1) {
        ["import"]=>
        string(33) "2007_Tax_Worksheet_JL_10-4-07.doc"
      }
    }
    ["type"]=>
    array(1) {
      ["Import"]=>
      array(1) {
        ["import"]=>
        string(18) "application/msword"
      }
    }
    ["tmp_name"]=>
    array(1) {
      ["Import"]=>
      array(1) {
        ["import"]=>
        string(27) "C:\uploaded_files\php1D.tmp"
      }
    }
    ["error"]=>
    array(1) {
      ["Import"]=>
      array(1) {
        ["import"]=>
        int(0)
      }
    }
    ["size"]=>
    array(1) {
      ["Import"]=>
      array(1) {
        ["import"]=>
        int(53760)
      }
    }
  }
}
see how it says that it's available now at "C:\uploaded_files\php1D.tmp" -- well it isn't there! :(

Posted: Wed Nov 28, 2007 6:33 pm
by ianhull
Yes, that is strange.

Have you restared the server since configuration?

Not sure what going on with this one.

have you tried using error checking?

Code: Select all

E_ALL

Posted: Wed Nov 28, 2007 6:38 pm
by Luke
I have tried the same script on my host and it worked. I tried it locally on another machine here and I got the same results as I did on my local machine. The files just WONT stay there. GRR where's a kitten when you need one?? Image

Posted: Wed Nov 28, 2007 6:41 pm
by ianhull
Are you using apache or IIS?

Posted: Wed Nov 28, 2007 6:42 pm
by Luke
apache

Posted: Wed Nov 28, 2007 7:28 pm
by ianhull
Can you post your .ini?

Posted: Thu Nov 29, 2007 1:54 am
by Kieran Huggins
Ole suggests checking for "allow_file_uploads" in PHP.ini... appendix i.

My thought is to try using Uniform Server and see if the problem persists.

For the kitten comment:
Image

Posted: Thu Nov 29, 2007 1:57 am
by Ollie Saunders
Kieran Huggins wrote:Ole suggests checking for "allow_file_uploads" in PHP.ini... appendix i.
Kieran is lazy. This is what I was referring to. You should check these configuration settings with ini_get() make sure they are what you're expecting. Otherwise I don't know what's going on.

Posted: Thu Nov 29, 2007 5:47 am
by volka
Could you please try

Code: Select all

<html>
	<body>
		<form enctype="multipart/form-data" action="?" method="POST">
			<div>
				Send this file: <input name="data[Import][import]" type="file" />
				<input type="submit" value="Send File" />
			</div>
		</form>
<?php
if ( isset($_FILES['data']['tmp_name']['Import']['import']) && 0==$_FILES['data']['error']['Import']['import'] ) {
	check(dirname($_FILES['data']['tmp_name']['Import']['import']));
	check($_FILES['data']['tmp_name']['Import']['import']);
}
else {
	echo 'upload failure.';
	echo '<pre>', var_dump($_FILES, true), "</pre>\n";
}

function check($path) {
	if ( !file_exists($path) ) {
		echo $path, " does not exist<br />\n";
	}
	else {
		echo
			is_dir($path) ? 'd':'-',
			is_readable($path) ? 'r':'-',
			is_writeable($path) ? 'w':'-',
			is_executable($path) ? 'x':'-',
			' ', $path;
		if ( is_file($path) ) {
			$fd = fopen($path, 'rb');
			if ( !$fd ) {
				echo '[ fopen failed ]';
			}
			else {
				fseek($fd, 0, SEEK_END);
				echo '[ ftell ', ftell($fd), ']';
				fclose($fd);
			}
		}
		echo "<br />\n";
	}
}
?>
	</body>
</html>