473,554 Members | 2,839 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 2318
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
3107
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...
4
2766
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...
1
7321
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...
7
4526
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
1487
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...
2
4418
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...
1
2071
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
1498
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...
3
5161
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
4104
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
7579
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...
0
7499
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...
0
7780
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8013
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...
0
7862
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...
0
6120
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5414
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...
0
3530
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1994
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.