ustawienia php.ini
Kod
file_uploads = On
upload_max_filesize = 100M
file_uploads = 1
upload_tmp_dir = "C:\AppServ\www\inc\tmp"
upload_max_filesize = 100M
file_uploads = 1
upload_tmp_dir = "C:\AppServ\www\inc\tmp"
Kod
<input type="hidden" name="MAX_FILE_SIZE" value="15000000" />
w MySQL
FILD--->file_size ---> int(6)---> unsigned --->0
a tu dodaje całość
<fieldset><legend>Fill out the form to upload a file:</legend> <input type="hidden" name="MAX_FILE_SIZE" value="15000000" /> <p><b>File:</b> <input type="file" name="upload" /></p> <p><b>Description:</b> <textarea name="description" cols="40" rows="5"></textarea></p> </fieldset> <div align="center"><input type="submit" name="submit" value="Submit" /></div> </form> <?php $page_title = 'Upload a File'; require_once ('config.php'); // Connect to the database. // Function for escaping and trimming form data. function escape_data ($data) { } } // End of escape_data() function. // Check for a description (not required). $d = escape_data($_POST['description']); } else { $d = ''; } // Add the record to the database. $query = "INSERT INTO uploads (file_name, file_size, file_type, description, upload_date) VALUES ('{$_FILES['upload']['name']}', {$_FILES['upload']['size']}, '{$_FILES['upload']['type']}', '$d', NOW())"; if ($result) { // Create the file name. $filename = $_FILES['upload']['name']; // Move the file over. } else { $query = "DELETE FROM uploads WHERE upload_id = $uid"; } } else { echo '<p><font color="red">Your submission could not be processed due to a system error. We apologize fo
r any inconvenience.</font></p>'; } } ?>