Forum Moderators: coopster
Here is a sample upload form:
<form enctype="multipart/form-data" action="example.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<input name="userfile" type="file" />
<input type="submit" value="Upload" />
</form>
That will generate a form with a browse button so that the user can browse and select the file for upload.
As far as the form handler, do you have knowledge of php or asp?
yeah but doing email attachments is never much fun.
have an upload form to allow the client to upload their logo then save it to some directory on your server where you can download it if needed. You could also have the uploader send you an email that a new logo has been uploaded.
if you really want email then just tell them to send it to you attached to an email. :)
try playing with this one
it needs mysql, it also creates a thumbnail.
It works well and you can play around with it to get the idea of how it works.
[webmasterworld.com...] msg #29
File/Dir structure on server:
form.php
upload.php
uploads/
1. Chmod uploads dir to 777 or make sure its writeable.
2. Create a page with this form (from kamakaze`s post) and call it form.php. Note I have take out the uploaded file size.
form.php
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input name="userfile" type="file" />
<input type="submit" name="submit" value="Upload" />
</form>
3. Create another file and call this upload.php. Set a maximum for uploads in bytes. This will process the upload:
upload.php
$max = '1048576'; //== 1MB
if (isset($_POST['submit']))
{$name = $_FILES['userfile']['name'];
$temp = $_FILES['userfile']['tmp_name'];
$size = $_FILES['userfile']['size'];if ($size < $max)
{if (is_uploaded_file($temp))
{move_uploaded_file($temp, 'uploads/' . $name);
if (file_exists('uploads/' . $name))
{echo "File Successfully Uploaded!";
}
else
{echo "File Not Uploaded";
}
}}
else
{echo "File Upload Too Big";
}
}
Hopefully that little code snippet helps you too. I don`t think I missed any braces. LOL.
dc
But to take it to the next stage....
How do display "please wait" graphic while the file is uploading?
I have found a few upload progress indicatior scripts (for example, MegaUpload) but they are far too complex for my project. I just want some way to let users know that the webpage is working and their file is uploading.
[edited by: Stu_Rogers at 10:49 am (utc) on Aug. 4, 2005]
HTML_Progress [pear.php.net]
Go to [phpclasses.org...] and check out the file upload classes.
You will need to register to download but they are free and there are some really useful code snippets.
dc
<form enctype="multipart/form-data" action="upload.php" method="POST">
Name: <input type="text" name="name">
E-Mail: <input type="text" name="email">
<input name="userfile" type="file" />
<input type="submit" name="submit" value="Upload" />
</form>
$_POST['name'], $_POST['email'] etc