RedLineIT
10-22-2004, 12:16 AM
Hello.
im having problems with an upload script.
here is the HTML form
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" name="form1">
<table width="261" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" bgcolor="#FEB30A"> </td>
</tr>
<tr>
<td width="77" bgcolor="#E1E8F2">Upload Pic :</td>
<td width="173"><input name="pic" type="file" class="smalltxt" id="pic"></td>
</tr><input type="hidden" name="MAX_FILE_SIZE" value="25">
<tr>
<td> </td>
<td><input name="Submit" type="submit" class="smalltxt" value="Upload !"></td>
</tr>
</table>
</form>
here is the PHP code that does it all
if ($_POST['Submit'])
{
$location = 'upload/' . $_FILES['pic']['name'];
if($_FILES['pic']['size'] > $_POST['MAX_FILE_SIZE']){
$messages = 'File Too Large';
}
if(move_uploaded_file($_FILES['pic']['tmp_name'], $location)) { echo "success"; exit(); } //move the file over
else {
echo 'failed';
exit();
i don't understand how i can
1 : get it to only allow gif , jpg files to be uploaded ( its allowing everything at the moment )
2 : make sure it doesnt move files greater than 25kb
ive searched and read loads of posts but im still confused. if anyone helps it will be very much appreciated
thanks
im having problems with an upload script.
here is the HTML form
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" name="form1">
<table width="261" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" bgcolor="#FEB30A"> </td>
</tr>
<tr>
<td width="77" bgcolor="#E1E8F2">Upload Pic :</td>
<td width="173"><input name="pic" type="file" class="smalltxt" id="pic"></td>
</tr><input type="hidden" name="MAX_FILE_SIZE" value="25">
<tr>
<td> </td>
<td><input name="Submit" type="submit" class="smalltxt" value="Upload !"></td>
</tr>
</table>
</form>
here is the PHP code that does it all
if ($_POST['Submit'])
{
$location = 'upload/' . $_FILES['pic']['name'];
if($_FILES['pic']['size'] > $_POST['MAX_FILE_SIZE']){
$messages = 'File Too Large';
}
if(move_uploaded_file($_FILES['pic']['tmp_name'], $location)) { echo "success"; exit(); } //move the file over
else {
echo 'failed';
exit();
i don't understand how i can
1 : get it to only allow gif , jpg files to be uploaded ( its allowing everything at the moment )
2 : make sure it doesnt move files greater than 25kb
ive searched and read loads of posts but im still confused. if anyone helps it will be very much appreciated
thanks