473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How to upload files above 1 MB in size?

Hello,
I am working on a site currently. And I did make it live but I had to put it off due to this problem I found. I saw other threads with kind of same problem as well but nothing seems to solve mine.
Here the php code I am using to upload files.
Expand|Select|Wrap|Line Numbers
  1.  </TR>
  2. <tr>
  3. <td><h3>File: </h3></td>
  4. <td width="200">
  5. <input type="hidden" name="MAX_FILE_SIZE" value="20000000">
  6. <input name="userfile" type="file" id="userfile">
  7. </td>
  8. <td width="50"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
  9. </tr>
  10. </table>
  11. </form>
  12. <?php
  13. if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
  14. {
  15. $description = $_REQUEST['description'];
  16. $cat = $_POST['Category'];
  17.  
  18. $fileName = $_FILES['userfile']['name'];
  19. $tmpName  = $_FILES['userfile']['tmp_name'];
  20. $fileSize = $_FILES['userfile']['size'];
  21. $fileType = $_FILES['userfile']['type'];
  22. $fp      = fopen($tmpName, 'r');
  23. $content = fread($fp, filesize($tmpName));
  24. $content = addslashes($content);
  25. fclose($fp);
  26. if(!get_magic_quotes_gpc())
  27. {
  28.   $fileName = addslashes($fileName);
  29. }
  30. $query = "INSERT INTO upload (name, size, type, content, description, username, category) ".
  31. "VALUES ('$fileName', '$fileSize', '$fileType', '$content', '$description', '$name', '$cat')";
  32. mysql_query($query) or die('Error, query failed');
  33.  
  34. echo "<br>Hurray!!!File $fileName has been successfully uploaded..Upload another file or go back to home<br>";
  35.  
This is the part responsible for the uploading of the files. So when I upload files with size less than 1 MB . they do get uploaded in the database table. I am using Longblob. But when I try to upload files with size more than that.. I get the "Error, query failed" message.

I checked the php.ini settings and the values are-
max_execution_time 300 --> in case it take too long to upload
post_max_size = 128 M
upload_max_filesize = 28 M
memory_limit = 128M

What could be wrong?
TIA
Chirag Narula
Dec 12 '10 #1
1 2655
dlite922
1,584 Expert 1GB
Try printing the error with mysql_error(). That should give you a better clue.


Dan
Dec 14 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jerry | last post by:
I'm having just a bit of trouble wrapping my brain around the task of working with folders that are above the site's root folder. I let users upload photos (.jpg/.gif files) which can...
2
by: Jim Lewis | last post by:
I need to upload files to a Web server from Flash MX. Flash does not have the ability to upload files. I have an example that uses a PHP page in the back ground to upload files...
2
by: Tom Wells | last post by:
I have a little file upload page that I have been able to use to successfully upload files to the C: drive of LocalHost (my machine). I need to be able to upload to a network drive from the intranet...
1
by: Prasath | last post by:
We are able to upload files to a localhost. Pl. help on uploading files to a remote web server using VB code Thanks
0
by: Gil | last post by:
Hello, In my local server i can upload my files but i could not upload files in webserver , i dont know what is problem. while executing the source code i get an error...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
1
by: avias | last post by:
Hi All, Could anyone please help me with this:- I am developing a web application using asp.net and I want to upload files automatically from the client to server. The paths(directory...
8
by: VUNETdotUS | last post by:
My goal is to upload files without submitting the form. I am not looking for the code here but rather a concept. I did a little research and discovered that I can submit a form to an invisible...
3
by: mp33487 | last post by:
I'm trying to upload/download files programmaticly to a records management system. I have it working fine on my dev machine using vb.net code-behind pages but when I place it on the server when it...
4
by: Stef Mientki | last post by:
hello, In a program I want to download (updated) files from google code (not the svn section). I could find a python script to upload files, but not for downloading. Anyone has a hint or a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.