Click to See Complete Forum and Search --> : uploading form
Heavy Metal
01-15-2006, 03:14 AM
I need the html form that uploads a file to the server, i can do this with php already but i need the form that allows the user to pick which file he wishes to upload and i also need to know the way to shorten down the file name from "C:\Documents and Settings\Username\My Documents\My Pictures\picture.jpg" to "picture.jpg" all help is greatly appreciated,
thanks
NogDog
01-15-2006, 03:24 AM
As per http://www.php.net/manual/en/features.file-upload.php#features.file-upload.post-method , the form will need to look something like:
<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="__URL__" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
In this example, since the file form element is named "userfile", the PHP form-handler could get the file name as: basename($_FILES['userfile']['name'])