Page 1 of 1
Simple File Upload Form
Posted: Sun Jan 22, 2006 4:48 pm
by nickman013
Hey,
I need help creating a simple, I mean simple photo upload form.
I just need it to make sure the file is a image, and it is under 5 megabytes.
Thank You!
Posted: Sun Jan 22, 2006 5:05 pm
by shiznatix
Posted: Sun Jan 22, 2006 5:05 pm
by raghavan20
You should get a plenty of code snippets for file upload and search in this forum as well.
File type and size come as natural attributes for INPUT type file
Look
here for basic information
Posted: Sun Jan 22, 2006 6:04 pm
by nickman013
ok
i have made the form, now i just need to make a upload script for the file (which i dont know how to do), and a email script (which i
do know how to do)
my form is:
Code: Select all
<form action=test.php method=post>
<table length=50 border=1>
<tr BGCOLOR=#A9A9A9>
<td>Your Name:</td><td><input type=text name=yourname length=20></td></tr>
<tr BGCOLOR=#A9A9A9>
<td>Muot's Name:</td><td><input type=text name=muotsname length=20></td></tr>
<tr BGCOLOR=#A9A9A9>
<td>Muot's Picture:</td><td><input type=file name=img[] size=30></td></tr>
<tr BGCOLOR=#A9A9A9>
<td>Muot's Nickname:</td><td><input type=text name=muotsnickname length=20></td></tr>
<tr BGCOLOR=#A9A9A9>
<td>Muot's Age:</td><td><input type=text name=moutsage length=3></td></tr>
<tr BGCOLOR=#A9A9A9>
<td>Muot's Location:</td><td><input type=text name=muotslocation length=20></td></tr>
<tr BGCOLOR=#A9A9A9>
<td>Muot's Sex:</td><td><input type=radio name=muotssex value=MALE>Male <input type=radio name=muotssex value=FEMALE>Female</td></tr>
<tr BGCOLOR=#A9A9A9>
<td>Muot's Weight:</td><td><input type=text name=muotsweight length=3></td></tr>
<tr BGCOLOR=#A9A9A9>
<td>Muot's Height:</td><td><input type=text name=muotsheight length=5></td></tr>
<tr BGCOLOR=#A9A9A9>
<td valign=top>Muot's Status:</td><td><textarea name=muotsstatus rows=10 cols=17 wrap=physical></textarea></td></tr>
<tr BGCOLOR=#A9A9A9>
<td valign=top>About This Muot:</td><td><textarea name=aboutthismuot rows=10 cols=17 wrap=physical></textarea></td></tr>
<tr BGCOLOR=#A9A9A9>
<td align=center colspan=2>
<input type=submit value="Submit the Muot!">
</td>
</tr>
</table>
</form>
I know how to make the email script but is there a way to get the URL of the submitted picture?
So What I need to get done:
1. Simple upload script that just has path, any image type, and max size to be 5MB, also the smalled and easiest script possible. Very BASIC!
2. Get a link of the submitted picture.
Thank You
Posted: Sun Jan 22, 2006 7:54 pm
by nickman013
i found the script i was looking for , it works beatifuly!
the script is
Code: Select all
<?
// Where the file is going to be placed
$target_path = "/home/muot/public_html/pages/muotreport/submitted/";
/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
// This is how we will get the temporary file...
$_FILES['uploadedfile']['tmp_name'];
$target_path = "/home/muot/public_html/pages/muotreport/submitted/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
?>
thank you everyone who helped!