View Single Post
  #6 (permalink)  
Old Jul 21st, 2006, 21:14
Gee Bee Gee Bee is offline
Up'n'Coming Member
Join Date: Jan 2006
Location: East Sussex
Age: 26
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Re: uploading files using online forms

ok so the forms input field should be something like;

<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
<input type="file" name="userfile" maxlength="50">

and the form should be ;

<form enctype="multipart/form-data" action="a_php_page.php" method="post" name='myForm'>

Then you need to move the file to a directory using the following;

move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name']);

You will also need the directory to exist, something like /myUploadedFiles for example in your document root, which also needs to have the appropriate write permissions associated with it.

Basically what happens is the file is uploaded using http from the form, this file is then saved in a temp directory (phpinfo() will tell you where it is) on the server so you then need to move it to the directory that you want to save it in. You should also really do a whole lot of checks on the file that you upload to a server to ensure it is what you think.

Hope this helps if not post again and i'll post a full script to help get it sorted for you, good luck!

Last edited by Gee Bee; Jul 22nd, 2006 at 07:53.
Reply With Quote