473,800 Members | 3,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error while uploading big files say 3.3mb

pradeepjain
563 Contributor
[PHP]<?php
mysql_connect(" localhost", "XXX", "xxx") OR DIE (mysql_error()) ;
mysql_select_db ("XXX") OR DIE ("Unable to select db".mysql_error ());
// our sql query
$str_sql1="sele ct Tnumber from Tenders where Tnumber = '".$_POST['Tnumber']."'";
$res_id1=mysql_ query($str_sql1 );
$rec_row=mysql_ fetch_row($res_ id1);
$rows=mysql_num _rows($res_id1) ;
if($rows > 0){

$msg = "Name already exists!!<br><IN PUT Type=\"Button\" Name=\"Back\" Value=\"Back\" onclick=\"histo ry.back()\" class=\"button\ ">" ;
print $msg;
}else{

?>
<?php
if($_FILES['userfile']['size'] < 30000000 )
{
$fileName = $_FILES['userfile']['name'];
//echo $fileName;
$tmpName = $_FILES['userfile']['tmp_name'];
//echo $tmpName;
$fileSize = $_FILES['userfile']['size'];
//echo $fileSize;
$fileType = $_FILES['userfile']['type'];
//echo $fileType;

$fp= fopen($tmpName , "rb");
$content = fread($fp, filesize($tmpNa me));//error for big files
$content = addslashes($con tent);
/*fclose($fp);*/

if(!get_magic_q uotes_gpc())
{
$fileName = addslashes($fil eName);
}

$date_arr=split ('[/ :]',$_POST['Posted']);
$Posted=$date_a rr[2]."-".$date_arr[1]."-".$date_arr[0];

$date_arr1=spli t('[/ :]',$_POST['Expires']);
$Expires=$date_ arr1[2]."-".$date_arr 1[1]."-".$date_arr 1[0];
/*
echo $Posted;
echo $Expires;
echo $_POST['Description'];
echo $_POST['Type'];
echo $fileName;
*/


mysql_connect(" localhost", "XXX", "XXX") OR DIE (mysql_error()) ;

// select the db
mysql_select_db ("XXX") OR DIE ("Unable to select db".mysql_error ());
$query = "insert into Tenders(Tnumber ,Description,Po sted,Expires,Na me,Type,Doc) VALUES ('".$_POST['Tnumber']."','".$_POS T['Description']." ','".$Posted."' ,'".$Expires."' ,'".$fileName." ','".$_POST['Type']."','".$content ."')";


mysql_query($qu ery) or die('Error, query failed');

require_once('X XX.tpl');

echo "<br>File $fileName uploaded<br>";

}
}
?>
[/PHP]

i am using this code it works very well for small files but as i upload big files it gives eror near the fopen line...can any one help on this
Nov 27 '07 #1
15 2338
pbmods
5,821 Recognized Expert Expert
Heya, Pradeep.

What error do you get?
Nov 27 '07 #2
pradeepjain
563 Contributor
hai pbmods,

warning: fread(): supplied argument is not a valid stream resource in /var/www/html/drupal/includes/common.inc(1343 ) : eval()'d code on line 29.


This is the error i get ..only for large files....and bcos of this error the download of the upload file is also not proper

any solution for this

Thanks,
pradeep
Nov 28 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, Pradeep.

Check $_FILES['userfile']['error'] and match it against this list.
Nov 28 '07 #4
pradeepjain
563 Contributor
[PHP] 1.
<?php
2.
mysql_connect(" localhost", "XXX", "xxx") OR DIE (mysql_error()) ;
3.
mysql_select_db ("XXX") OR DIE ("Unable to select db".mysql_error ());
4.
// our sql query
5.
$str_sql1="sele ct Tnumber from Tenders where Tnumber = '".$_POST['Tnumber']."'";
6.
$res_id1=mysql_ query($str_sql1 );
7.
$rec_row=mysql_ fetch_row($res_ id1);
8.
$rows=mysql_num _rows($res_id1) ;
9.
if($rows > 0){
10.

11.
$msg = "Name already exists!!<br><IN PUT Type=\"Button\" Name=\"Back\" Value=\"Back\" onclick=\"histo ry.back()\" class=\"button\ ">" ;
12.
print $msg;
13.
}else{
14.

15.
?>
16.
<?php
17.
if($_FILES['userfile']['size'] < 30000000 )
18.
{
19.
$fileName = $_FILES['userfile']['name'];
20.
//echo $fileName;
21.
$tmpName = $_FILES['userfile']['tmp_name'];
22.
//echo $tmpName;
23.
$fileSize = $_FILES['userfile']['size'];
24.
//echo $fileSize;
25.
$fileType = $_FILES['userfile']['type'];
26.
//echo $fileType;
27.
$error = $_FILES['userfile']['error'];/* here*/
28.echo $error;
$fp= fopen($tmpName , "rb");
29.
$content = fread($fp, filesize($tmpNa me));//error for big files
30.
$content = addslashes($con tent);
31.
/*fclose($fp);*/
32.

33.
if(!get_magic_q uotes_gpc())
34.
{
35.
$fileName = addslashes($fil eName);
36.
}
37.

38.
$date_arr=split ('[/ :]',$_POST['Posted']);
39.
$Posted=$date_a rr[2]."-".$date_arr[1]."-".$date_arr[0];
40.

41.
$date_arr1=spli t('[/ :]',$_POST['Expires']);
42.
$Expires=$date_ arr1[2]."-".$date_arr 1[1]."-".$date_arr 1[0];
43.
/*
44.
echo $Posted;
45.
echo $Expires;
46.
echo $_POST['Description'];
47.
echo $_POST['Type'];
48.
echo $fileName;
49.
*/
50.

51.

52.
mysql_connect(" localhost", "XXX", "XXX") OR DIE (mysql_error()) ;
53.

54.
// select the db
55.
mysql_select_db ("XXX") OR DIE ("Unable to select db".mysql_error ());
56.
$query = "insert into Tenders(Tnumber ,Description,Po sted,Expires,Na me,Ty pe,Doc) VALUES ('".$_POST['Tnumber']."','".$_POS T['Description']." ','".$Posted."' ,'".$Expires."' ,'".$fileName." ','".$_POST['Type']."','".$content ."')";
57.

58.

59.
mysql_query($qu ery) or die('Error, query failed');
60.

61.
require_once('X XX.tpl');
62.

63.
echo "<br>File $fileName uploaded<br>";
64.

65.
}
66.
}
67.
?>[/PHP]




as u said i added tht line of code and checked ..no error msg came ..
Nov 29 '07 #5
pradeepjain
563 Contributor
wht exactly might be the prob...bcso it works well fro small files naa.
Nov 29 '07 #6
pradeepjain
563 Contributor
Heya, Pradeep.

Check $_FILES['userfile']['error'] and match it against this list.

hey tht error tht i had posted is gone....but for large files its showing
"Error, query failed" ......so whts the problem with the large files
Nov 29 '07 #7
pbmods
5,821 Recognized Expert Expert
Heya, Pradeep.

I'd bet that the problems is that either PHP's upload_max_file size directive or else the MAX_FILE_SIZE value is too low.
Nov 29 '07 #8
pradeepjain
563 Contributor
Heya, Pradeep.

I'd bet that the problems is that either PHP's upload_max_file size directive or else the MAX_FILE_SIZE value is too low.

the file size tht i am trying to upload is 3426132 and the MAX_FILE_SIZE tht is being set is "3000000000 00" .....so id ont think ist an prob....can there be any php setting or an issue with the host
Nov 30 '07 #9
pbmods
5,821 Recognized Expert Expert
Heya, Pradeep.

What about upload_max_file size?
Nov 30 '07 #10

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

Similar topics

0
3114
by: Marc | last post by:
Hello, I have a page where i can upload binary file (using the HTML input type=file approach). This works fine for relatively small files (<6MB)) but when files get bigger (13MB) there is a problem. The code of the php file is based upon the article in http://www.onlamp.com/pub/a/php/2000/09/15/php_mysql.html: uploading large binary files using more than one table and more trhan 1 row per file.
4
2779
by: dickiedyce | last post by:
Hi there. I've spent the weekend getting ever more frustrated, trying to get an upload file function working on a website. The site is hosted by a company called oneandone. They're using PHP 4.2. 3, not in safe mode. I think that the basic problem is the set-up for the temp folder, but I don't have access to the .ini settings. I'm pretty sure it's possible, because I've got MyPHPAdmin running, and
1
7341
by: Nikhil | last post by:
I have a VBscript that I use to upload files onto the server. The script works fine on IIS 5.0 but on IIS 6.0 on Windows 2003 I get an error when uploading certain files. I believe its because the file is larger than what is normally uploaded. Average file size is 15KB this file is 490Kb. The error that I get is Request object error 'ASP 0104 : 80004005' Operation not
7
4540
by: Joe | last post by:
I have an upload file operation in the web application. UploadForm.asp is the form, and UploadAction.asp is the form processing. //UploadForm.asp <FORM NAME="InputForm" ACTION="UploadAction.asp" METHOD="POST" enctype=multipart/form-data> <input type="file" name="fileName"> //etc ... </FORM>
5
1507
by: hb | last post by:
Hi, In my ASP.Net application 'MyWebApp' , the mode="StateServer" in <sessionState> of Web.config file, and the ASP.NET State Service is set to start automatically on the server. But every time when I update the application's MyWebApp.dll file in \bin folder by simply uploading a new MyWebApp.dll file to override the old one in the same folder,
2
4438
by: GD | last post by:
Hi, An intranet application, with a SMTP mail function that lets users to attach files with emails by selecting files in their local computers (through a file browser component), works perfect on my local machine. However, after deployment to a server that has Windows 2003 Sever installed, the mail function is able to attach the file created by the application. However, when users attach some files selected from their local machines, it...
1
2082
by: wenqiang7 | last post by:
I am encountering a very strang problem with file uploading in my ASP.Net page. When we try to upload certain file, we'll get an error msg of "Cannot find server or DNS Error". We are running on Win2003, IIS, ASP.Net 1.1. The page works fine if running from localhost. It only has problem when accessed from a domain name.
0
1504
by: PerumalSamy | last post by:
Hi, I am getting following error while uploading my project in web. Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: File or assembly name CrystalDecisions.CrystalReports.Engine, or one of its dependencies, was not found. Source Error:
3
5184
by: muziburrehaman | last post by:
i am looking for code in php to upload the 1 gb files. any one can please help me by sending the code....
4
4119
rahulephp
by: rahulephp | last post by:
i think i am missing something in the below script: It shows error an do not upload files to destination: Let me know how to solve this: <?php if (isset($_POST)) { $uploadArray= array();
0
9694
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9553
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10281
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10256
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10039
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7584
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6824
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2953
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.