dtayler
-
Posts
2 -
Joined
-
Last visited
Never
Posts posted by dtayler
-
-
I am having a problem with accessing the $_FILES array. I find that it sometimes has data in, and sometimes is empty! (I have to submit the first file, go back, submit again....several times, and then will get data) I am running Apache locally, and have checked the php settings for max file size, upload allowed, global variables etc., as recommended in the articles I've found on this. My code is in two php files as given below. PLEASE can somebody help.
upload.php
html>
<head></head>
<body>
<form enctype="multipart/form-data" method="post" action="upload2.php" >
<input type="file" name="newname">
<input type="submit">
</form>
</body>
</html>
upload2.php
html>
<head></head>
<body>
<?php
echo '<br> Files contains: name :'.$_FILES['newname']['name'].' temp :'.$_FILES['newname']['tmp_name'].' type :'.$_FILES['newname']['type'].' size :'.$_FILES['newname']['size'].' error :'.$_FILES['newname']['error'].'<br>';
?>
</body>
</html>
Uploading Files
in PHP Coding Help
Posted
Change you test to be the following and see if you have the same problem:
[code]
<?php
if (isset($_POST['submit'])) echo '<pre>' . print_r($_FILES,true) . '</pre>';
?>
<html>
<head></head>
<body>
<form enctype="multipart/form-data" method="post" action="<? echo $_SERVER['PHP_SELF'] ?>" >
<input type="file" name="newname"><br>
<input type="submit" name="submit" value="Upload File">
</form>
</body>
</html>[/code]
With this code you don't have to hit the "back" button to get back to the form and the dump the $_FILES array is nicely formatted.
Ken
[/quote]
Thanks Ken, it's easier than going back a page all the time - but I still get the same problem!
Deb