[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
15 2318 pbmods 5,821
Recognized Expert Expert
Heya, Pradeep.
What error do you get?
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
pbmods 5,821
Recognized Expert Expert
Heya, Pradeep.
Check $_FILES['userfile']['error'] and match it against this list.
[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 ..
wht exactly might be the prob...bcso it works well fro small files naa.
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
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
pbmods 5,821
Recognized Expert Expert
Heya, Pradeep.
What about upload_max_file size?
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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>
|
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...
| |
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: 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.
|
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...
|
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....
|
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();
|
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...
| |
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...
|
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. ...
|
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...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |