473,503 Members | 9,903 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="select 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><INPUT Type=\"Button\" Name=\"Back\" Value=\"Back\" onclick=\"history.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($tmpName));//error for big files
$content = addslashes($content);
/*fclose($fp);*/

if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}

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

$date_arr1=split('[/ :]',$_POST['Expires']);
$Expires=$date_arr1[2]."-".$date_arr1[1]."-".$date_arr1[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,Posted,Expires,Name,Ty pe,Doc) VALUES ('".$_POST['Tnumber']."','".$_POST['Description']." ','".$Posted."','".$Expires."','".$fileName."','". $_POST['Type']."','".$content."')";


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

require_once('XXX.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 2314
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="select 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><INPUT Type=\"Button\" Name=\"Back\" Value=\"Back\" onclick=\"history.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($tmpName));//error for big files
30.
$content = addslashes($content);
31.
/*fclose($fp);*/
32.

33.
if(!get_magic_quotes_gpc())
34.
{
35.
$fileName = addslashes($fileName);
36.
}
37.

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

41.
$date_arr1=split('[/ :]',$_POST['Expires']);
42.
$Expires=$date_arr1[2]."-".$date_arr1[1]."-".$date_arr1[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,Posted,Expires,Name,Ty pe,Doc) VALUES ('".$_POST['Tnumber']."','".$_POST['Description']." ','".$Posted."','".$Expires."','".$fileName."','". $_POST['Type']."','".$content."')";
57.

58.

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

61.
require_once('XXX.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_filesize 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_filesize 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 "300000000000" .....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_filesize?
Nov 30 '07 #10
pradeepjain
563 Contributor
Heya, Pradeep.

What about upload_max_filesize?

upload_max_filesize????.....hey i hve not used anything of such type...
where do we need to use it...


[HTML]<td valign="top" class="subheading">Doc<span class="mandatory">*</span>:</td>
<input type="hidden" name="ID" value="<?php $Colloquiums[$nr][ID] ?>">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000000000" />
<td><input name="userfile" type="file" size="35" /></td>[/HTML]


this is wht i hve used...
Dec 1 '07 #11
pradeepjain
563 Contributor
upload_max_filesize????.....hey i hve not used anything of such type...
where do we need to use it...


[HTML]<td valign="top" class="subheading">Doc<span class="mandatory">*</span>:</td>
<input type="hidden" name="ID" value="<?php $Colloquiums[$nr][ID] ?>">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000000000" />
<td><input name="userfile" type="file" size="35" /></td>[/HTML]


this is wht i hve used...


hey pbmods,
wht happened y no replies
Dec 4 '07 #12
pradeepjain
563 Contributor
hey pbmods,
wht happened y no replies
hey this is the new error

Got a packet bigger than 'max_allowed_packet' bytes
Dec 4 '07 #13
pbmods
5,821 Recognized Expert Expert
Heya, Pradeep.

upload_max_filesize is defined in php.ini.

Check out this page.
Dec 5 '07 #14
mwasif
802 Recognized Expert Contributor
You are getting max_allowed_packet error due to MySQL configuration. I have answered your question related this problem in MySQL Forum.
Dec 5 '07 #15
pradeepjain
563 Contributor
ok thanks for ur help pdmos.my problem is solved..wll seek help when eer its required.

Thanks,
Pradeep
Dec 10 '07 #16

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

Similar topics

0
3100
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...
4
2762
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...
1
7313
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...
7
4520
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"...
5
1480
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...
2
4416
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...
1
2066
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...
0
1491
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...
3
5157
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
4089
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=...
0
7207
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
7095
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...
0
7294
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,...
0
7361
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...
1
7015
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
5602
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,...
1
5026
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...
0
4693
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...
0
403
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...

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.