It worked perfectly!
ES Simple Uploader Script located at
http://www.hotscripts.com/PHP/Scripts_and_Programs/File_Manipulation/Upload_Systems/index.html
If anyone else is on their learning curve...
-Pete
At 04:56 PM 05/21/2006, P. Guethlein wrote:
I'm still very frustrated trying to figure out how to upload a
file. I must have tried 15 different coding examples and none of them work.
When I try and debug and do a
print_r($_FILES);
All I'm getting back is array() with no data.
File upload is allowed in my php.ini
Can anyone offer any other insight before my laptop sails into the
wall ?<smile>
Thanks, -Pete
At 02:03 PM 05/21/2006, tedd wrote:
At 1:52 AM -0700 5/21/06, P. Guethlein wrote:
I'm at one of those frustration levels.... can't seem to get a
script working that will post and upload a file to the
server. I"m working with the below. Can you help?
Guethlein:
Yes, try this -- watch for line breaks. Also, create folders "uploads/tmp".
The code works "as is" for me except that I have to give the "tmp"
folder 0777 permissions* because the code runs as "nobody". I
haven't figured out how to get around that, but I can change the
uploaded file's permissions without error. (If anyone wants to show
me OFF-LIST how to do this without setting the tmp folder to 0777,
I'm all ears, but don't beat me up because I'm trying to learn.)
Code follows:
<?php
// This allows users to upload files to the server.
if (isset($_POST['submit'])) // handle the form -- start of main
Submit conditional..
{
// Create the file name.
$filename = $_FILES['upload']['name'];
$file_loaded = 0;
// Move the file over.
if (move_uploaded_file($_FILES['upload']['tmp_name'],
"uploads/tmp/$filename"))
{
echo '<p>The file has been uploaded to the server.</p>';
chmod("uploads/tmp/$filename", 0755);
echo ( '<p>' . $filename . '</p>' );
}
else
{
echo ('<p><font color="red">ERROR: The file was not upload.</font></p>');
}
}
else
{
?>
<form enctype="multipart/form-data" action="<?php echo
$_SERVER['PHP_SELF']; ?>" method="post">
<p>
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
</p>
<fieldset>
<legend>Select the file to upload:</legend>
<p>
<b>File:</b>
<input type="file" name="upload" />
</p>
</fieldset>
<p>
<input type="submit" name="submit" value="Submit" />
</p>
</form>
<?php
}
?>
hth's
tedd
* Larry Ullman in his books says to use 0777 permission for
uploading files. However, he does say that it is less secure and
should be placed outside of the web directory.
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php