I'm using this uploading script. But I come across a lot of errors. I like this script because it offers, upload into mulitple folders and stuff. It claims to only let you upload certain types of file, and filesize extensions.
But when I test it out, it doesn't do as it claim. Like you can upload anyfiles you want, and there is no filesize limit. When you upload any files, it just changes the extension to the file size I put. Weird...
this is the entire code below...I don't know anything about php. could someone point me to a good file uploaded script that will let me upload certain types of file and limit file size. Also upload into different directories.
<table width="100%" cellspacing="2" cellpadding="2" height="100%">
<tr>
<td>
<div align="center">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="100%" cellpadding="5" cellspacing="5">
<tr>
<td>
<form name="formen" action="submit.php" method="post" enctype="multipart/form-data">
<font class="3d">
When Uploading, please upload to correct folders. Please choose the folder
that best describes the cursor you are uploading. We only allow uploading
of .cur, .ani, and .zip files. If you want to upload a larger file size
file, please use the contact form and get our e-mail address and use your
e-mail service provider and attach the file. We do not have the resources
to check for viruses or hazardous files, that's why we limit file size
to 50kb.<br><br>
Max filesize: 50kb.<br>
File Type: .cur, .ani, .zip
</font>
<br><br>
<table width="100%" cellspacing="2" cellpadding="2">
<tr>
<td width="180"><font class="3d">File:</font> </td>
<td>
<input type="file" name="bilde_fil">
</td>
</tr>
<tr>
<td width="180"><font class="3d">Choose folder:</font></td>
<td>
<select name="folder">
<option>Choose folder</option>
<option value="uploaded_animals/">Animals</option>
<option value="uploaded_cartoons/">Cartoons</option>
<option value="uploaded_holidays/">Holidays</option>
<option value="uploaded_sports/">Sports</option>
<option value="uploaded_items/">Items</option>
<option value="uploaded_vehicles/">Vehicles</option>
<option value="uploaded_others/">Others</option>
</select>
</td>
</tr>
<tr>
<td width="180"><font class="3d">Please Name File:</font></td>
<td>
<input type="text" name="nyttnavn">
</td>
</tr>
<tr>
<td width="180"><font class="3d">Filetype:</font></td>
<td>
<select name="ending">
<option>.cur</option>
<option>.ani</option>
<option>.zip</option>
</select>
</td>
</tr>
</table>
<br>
<input type="submit" value="Upload" name="submit">
<input type="hidden" name="MAX_FILE_SIZE" value="5000">
<?php if ($folder == "Choose folder")
{
echo "<b>Error: </b> You must Choose a folder to upload your file.";
}?>
<?php
#Config
$path=$folder; //The file-path(remember the last '/')
#Do not edit below :)
if ($bilde_fil && $nyttnavn){
$ok = 1;
if (is_file($path.$nyttnavn.$ending)){
print "<b>Error</b>, the name allready exists. Choose another name.<br>";
$ok = 0;
}
if (preg_match("/^[\/\\\.]/", $nyttnavn)){
print "<b>Error</b>, Filname can't start with: '.', '/' or '\'";
$ok = 0;
}
if (!($ending == ".cur" || $ending == ".ani" || $ending == ".zip")){
print "<b>Error</b>, do not mix with the filename ($ending) Thanks!";
$ok = 0;
}
print "";
}
if ($ok){
$res = copy($bilde_fil, $path."/".$nyttnavn.$ending);
print ($res)?"":"<b>Error</b>, could not upload the file.<br>";
print "";
}
?>
</form>
</td>
</tr>
</table>