CODE
if ($_POST["action"] == "Upload") {
$folder = "storages/";
move_uploaded_file($_FILES["filep"]["tmp_name"] , "$folder".$_FILES["filep"]["name"]);
echo "<br/>
<p align=center>Filename \"<b>".$_FILES["filep"]["name"]. "</b>\" Loaded";
$resultz = mysql_query("INSERT into storages VALUES($_POST[fileid],'".$_FILES['filep']['name']."','$_POST[entrydesc]')");
if($resultz) {
echo "<script>self.location='adminpage.php'</script>";
}
}
echo "<tr>
<td><input type='hidden' name='fileid' value=". $curid ." /></td>
</tr>
<tr>
<input type='hidden' name='MAX_FILE_SIZE' value='10000000' />
<td style='padding: 3px 10px 0px 50px;font:12px tahoma'>Filename</td>
<td><input type='file' name='filep' /></td>
</tr>
<tr valign='top'>
<td style='padding: 3px 10px 0px 50px;font:12px tahoma'>File Description</td>
<td><textarea style='width:350px;height:150px' name='entrydesc'></textarea></td>
</tr>
<tr>
<td><input type='hidden' name='dates' value=" . $dates ." /></td>
<td colspan='2' align='right'><input type='submit' name='action' value='Upload' /></td>
</tr>";
hi this is my code in uploading my files to a folder in root directory and the filename to the mysql database. it works but my question is..how do i set restriction like if the file already exist there should error message that says the filename is already exist or something..how do i do that and where can i place it??
This post has been edited by rkmalbz: 5 Nov, 2009 - 03:05 PM