j.silver Posted November 18, 2016 Share Posted November 18, 2016 Dear all, I have the following code for storing an image in and fetching it from a MySQL DB: <html> <body> <form action="index.php" method="POST" enctype="multipart/form-data"> File: <input type="file" name="image"> <input type="submit" value="upload"> </form> <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("code_new") or die(mysql_error()); $file = $_FILES['image']['tmp_name']; if(!isset($file)) { echo 'Please select a file'; } else { $image = addslashes(file_get_contents($_FILES['image']['tmp_name'])); $image_name = addslashes($_FILES['image']['name']); $image_size = getimagesize($_FILES['image']['tmp_name']); if ($image_size == FALSE) echo 'This is not an image.'; else { if(!$insert = mysql_query("INSERT INTO lash VALUES ('', '$image_name', '$image')")) { echo 'Problem uploading the image.'; } else { $lastid = mysql_insert_id(); echo "Image uploaded.<p />Your Image:<p /><img src=get.php?id=$lastid>"; } } } ?> </body> </html> No need to include get.php and the DB. To test the if statement in red, I attempted to upload a pdf file and it functioned well. It also uploaded various images. But when I attempted to upload a docx file (word), the following occurred: Warning: POST Content-Length of 9069583 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 What is the meaning of this warning and what are the Unknown and line 0? Link to comment Share on other sites More sharing options...
Ingolme Posted November 18, 2016 Share Posted November 18, 2016 It means the file you tried to upload was much too large. You can set the maximum post size and maximum file upload size in php.ini. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now