Simple code. I didnt do any file checking. All files type are allowed. Coz everyone can upload files and share it.
<form name="fileform" method="POST" action="upload_process.php" enctype="multipart/form-data">
File: <input type="file" name="thefile">
</form>
upload_process.php
<?php
if (move_uploaded_file($_FILES['thefile']['tmp_name'], $uploadfile))
{
$sql="INSERT INTO file_upload SET file_name='$file_name', file_type='$file_type', file_size='$file_size',
file_modified='$file_modified', file_desc='$file_desc', file_catid='$file_catid'";
mysql_query($sql, $db) or die("Could not execute sql");
print "File is valid, and was successfully uploaded. ";
} else {
print "File is not valid. Please check whether file exist.\n";
}
?><br><br>
One funny problem. I test this on IIS / localhost / Winxp and it works without any problem. Limit in php.ini is 10MB.
But when i transfer it to Linux 9 server, it only can upload files that are less than 1MB WITHOUT problems. (It goes to upload_process.php)
The problem is when i upload files that are more than 1MB. After clicking the upload button, it is directed to those page where page is not found/broken link. Why doesn't it goes to the upload_process.php and AT LEAST display the File is not valid.....if it didnt upload successfully. 😕