Hi,
I have a short basic script to upload files. It works fine with small files,
but with longer files it gets stuck.
Here's the fragment, the input file is loaded in "$file" from an HTML form
as usual.
....
$img_str = fread(fopen($file, "r"), filesize($file));
$data = addslashes($img_str);
// --------------------- up to here the execution is correct and fast (<1
second)
$sql="INSERT INTO $table (".
" file_name,".
" file_type,".
" file_size,".
" bin_data)".
" VALUES (".
" '$file_name',".
" '$file_type',".
" '$file_size',".
" '$data')";
// --------------------- it gets stuck
here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
mysql_query($sql) or die ("SQL error ..$sql");
I have already set the php.ini variables as follows:
memory_limit = 16M
upload_max_filesize = 6M
I also checked the execution time to max_execution_time = 300 (even though I
don't believe it should be necessary).
The server is a P4 1.8 GHz, 256MB RAM
Any suggestion? Am I missing out something?
Thanks in advance,
G. 6 2524
Giulio Neri wrote: Hi, I have a short basic script to upload files. It works fine with small files, but with longer files it gets stuck.
Here's the fragment, the input file is loaded in "$file" from an HTML form as usual.
... $img_str = fread(fopen($file, "r"), filesize($file)); $data = addslashes($img_str); // --------------------- up to here the execution is correct and fast (<1 second)
$sql="INSERT INTO $table (". " file_name,". " file_type,". " file_size,". " bin_data)". " VALUES (". " '$file_name',". " '$file_type',". " '$file_size',". " '$data')";
Are you aware that the query is very strange?
Since you put ' instead of " around stringliterals, the SQL you produce
might differ somewhat from what you expect.
Always try:
echo $sql;
before posting to a newsgroup. :P
You will have something like this:
INSERT INTO sometable (file_name,file_type,file_size,bin_data)
VALUES
('$file_name', '$file_type' etc. etc)
instead of the expected VALUES for the vars you use.
Check your ' and "
Regards,
Erwin Moller
// --------------------- it gets stuck here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! mysql_query($sql) or die ("SQL error ..$sql");
I have already set the php.ini variables as follows: memory_limit = 16M upload_max_filesize = 6M
I also checked the execution time to max_execution_time = 300 (even though I don't believe it should be necessary). The server is a P4 1.8 GHz, 256MB RAM
Any suggestion? Am I missing out something?
Thanks in advance, G.
Erwin,
the single quotation mark is required in the sql syntax to insert text /
non-numeric values (mysql gives me an error otherwise).
The real problem here is that the string concatenation fails and I cannot
make it work...
I also tried with something like:
$sql="hello: $data";
or
$sql="hello: " . $data;
and in both cases it fails (I believe it runs out of memory...).
The file size is 4MB.
Thanks for any additional advise.
G.
"Erwin Moller"
<si******************************************@spam yourself.com> wrote in
message news:42***********************@news.xs4all.nl... Giulio Neri wrote:
Hi, I have a short basic script to upload files. It works fine with small files, but with longer files it gets stuck.
Here's the fragment, the input file is loaded in "$file" from an HTML
form as usual.
... $img_str = fread(fopen($file, "r"), filesize($file)); $data = addslashes($img_str); // --------------------- up to here the execution is correct and fast
(<1 second)
$sql="INSERT INTO $table (". " file_name,". " file_type,". " file_size,". " bin_data)". " VALUES (". " '$file_name',". " '$file_type',". " '$file_size',". " '$data')";
Are you aware that the query is very strange? Since you put ' instead of " around stringliterals, the SQL you produce might differ somewhat from what you expect.
Always try: echo $sql; before posting to a newsgroup. :P
You will have something like this:
INSERT INTO sometable (file_name,file_type,file_size,bin_data) VALUES ('$file_name', '$file_type' etc. etc)
instead of the expected VALUES for the vars you use.
Check your ' and "
Regards, Erwin Moller
// --------------------- it gets stuck here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! mysql_query($sql) or die ("SQL error ..$sql");
I have already set the php.ini variables as follows: memory_limit = 16M upload_max_filesize = 6M
I also checked the execution time to max_execution_time = 300 (even
though I don't believe it should be necessary). The server is a P4 1.8 GHz, 256MB RAM
Any suggestion? Am I missing out something?
Thanks in advance, G.
Giulio Neri wrote: Erwin, the single quotation mark is required in the sql syntax to insert text / non-numeric values (mysql gives me an error otherwise).
Right,
But did you echo the SQL-string before executing?
What came out?
Regards,
Erwin Moller
The real problem here is that the string concatenation fails and I cannot make it work...
that is why I advised you to check the ' and " in the first place.
Try something like this.
$sql="INSERT INTO $table (file_name,file_type,file_size,bin_data)";
$sql.= "VALUES ('".$file_name"', '".$file_type."' etc. etc
Just use . to concatenate.
Good luck.
Let me/us know if you succeed.
Regards,
Erwin Moller I also tried with something like:
$sql="hello: $data";
or
$sql="hello: " . $data;
and in both cases it fails (I believe it runs out of memory...).
The file size is 4MB.
Thanks for any additional advise. G.
"Erwin Moller" <si******************************************@spam yourself.com> wrote in message news:42***********************@news.xs4all.nl... Giulio Neri wrote:
> Hi, > I have a short basic script to upload files. It works fine with small > files, but with longer files it gets stuck. > > Here's the fragment, the input file is loaded in "$file" from an HTML form > as usual. > > ... > $img_str = fread(fopen($file, "r"), filesize($file)); > $data = addslashes($img_str); > // --------------------- up to here the execution is correct and fast (<1 > second) > > $sql="INSERT INTO $table (". > " file_name,". > " file_type,". > " file_size,". > " bin_data)". > " VALUES (". > " '$file_name',". > " '$file_type',". > " '$file_size',". > " '$data')";
Are you aware that the query is very strange? Since you put ' instead of " around stringliterals, the SQL you produce might differ somewhat from what you expect.
Always try: echo $sql; before posting to a newsgroup. :P
You will have something like this:
INSERT INTO sometable (file_name,file_type,file_size,bin_data) VALUES ('$file_name', '$file_type' etc. etc)
instead of the expected VALUES for the vars you use.
Check your ' and "
Regards, Erwin Moller
> // --------------------- it gets stuck > here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! > mysql_query($sql) or die ("SQL error ..$sql"); > > I have already set the php.ini variables as follows: > memory_limit = 16M > upload_max_filesize = 6M > > I also checked the execution time to max_execution_time = 300 (even though > I don't believe it should be necessary). > The server is a P4 1.8 GHz, 256MB RAM > > Any suggestion? Am I missing out something? > > Thanks in advance, > G.
Hi Erwin,
I did insert a exit($sql); before executing as well as a exit("test");
in both cases the program did not reach the exit command line
It is almost definitely something to do with the string concatenation, as
many other tests I have done show and I don;t know how to get around that!
Thanks for helping me.
"Erwin Moller"
<si******************************************@spam yourself.com> wrote in
message news:42***********************@news.xs4all.nl... Giulio Neri wrote:
Erwin, the single quotation mark is required in the sql syntax to insert text / non-numeric values (mysql gives me an error otherwise).
Right,
But did you echo the SQL-string before executing? What came out?
Regards, Erwin Moller
The real problem here is that the string concatenation fails and I
cannot make it work...
that is why I advised you to check the ' and " in the first place.
Try something like this.
$sql="INSERT INTO $table (file_name,file_type,file_size,bin_data)"; $sql.= "VALUES ('".$file_name"', '".$file_type."' etc. etc
Just use . to concatenate.
Good luck. Let me/us know if you succeed.
Regards, Erwin Moller
I also tried with something like:
$sql="hello: $data";
or
$sql="hello: " . $data;
and in both cases it fails (I believe it runs out of memory...).
The file size is 4MB.
Thanks for any additional advise. G.
"Erwin Moller" <si******************************************@spam yourself.com> wrote in message news:42***********************@news.xs4all.nl... Giulio Neri wrote:
> Hi, > I have a short basic script to upload files. It works fine with small > files, but with longer files it gets stuck. > > Here's the fragment, the input file is loaded in "$file" from an HTML form > as usual. > > ... > $img_str = fread(fopen($file, "r"), filesize($file)); > $data = addslashes($img_str); > // --------------------- up to here the execution is correct and
fast (<1 > second) > > $sql="INSERT INTO $table (". > " file_name,". > " file_type,". > " file_size,". > " bin_data)". > " VALUES (". > " '$file_name',". > " '$file_type',". > " '$file_size',". > " '$data')";
Are you aware that the query is very strange? Since you put ' instead of " around stringliterals, the SQL you produce might differ somewhat from what you expect.
Always try: echo $sql; before posting to a newsgroup. :P
You will have something like this:
INSERT INTO sometable (file_name,file_type,file_size,bin_data) VALUES ('$file_name', '$file_type' etc. etc)
instead of the expected VALUES for the vars you use.
Check your ' and "
Regards, Erwin Moller
> // --------------------- it gets stuck > here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! > mysql_query($sql) or die ("SQL error ..$sql"); > > I have already set the php.ini variables as follows: > memory_limit = 16M > upload_max_filesize = 6M > > I also checked the execution time to max_execution_time = 300 (even though > I don't believe it should be necessary). > The server is a P4 1.8 GHz, 256MB RAM > > Any suggestion? Am I missing out something? > > Thanks in advance, > G.
Giulio Neri wrote: Hi Erwin, I did insert a exit($sql); before executing as well as a exit("test");
in both cases the program did not reach the exit command line
It is almost definitely something to do with the string concatenation, as many other tests I have done show and I don;t know how to get around that!
Thanks for helping me.
Did you read the rest of my posting?
It contained an improved $sql statement.
Try to use it in your situation.
(I said 2 times, 'Regards, Erwin Moller')
So that probably made you stop reading after the first. :P
Sorry.
Regards,
Erwin Moller
The syntax I used is the same reported in many SQL, MySQL and PHP manuals.
Anyway I solved the problem:
1- increased memory available to script
memory_limit = 16M
upload_max_filesize = 6M
2- use of unset($temp_variables) in order to release memory
3- set mysql configuration file option:
max_allowed_packet=16M
It all works now...
Thanks anyway,
G.
"Erwin Moller"
<si******************************************@spam yourself.com> wrote in
message news:42***********************@news.xs4all.nl... Giulio Neri wrote:
Hi Erwin, I did insert a exit($sql); before executing as well as a exit("test");
in both cases the program did not reach the exit command line
It is almost definitely something to do with the string concatenation,
as many other tests I have done show and I don;t know how to get around
that! Thanks for helping me.
Did you read the rest of my posting? It contained an improved $sql statement. Try to use it in your situation.
(I said 2 times, 'Regards, Erwin Moller') So that probably made you stop reading after the first. :P Sorry.
Regards, Erwin Moller This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: matt |
last post by:
I have compiled some code, some written by me, some compiled from
various sources online, and basically i've got a very simple flat file
photo gallery. An upload form, to upload the photos and give...
|
by: pruebauno |
last post by:
Hello all,
I am having issues compiling Python with large file support. I tried
forcing the configure script to add it but then it bombs in the make
process. Any help will be appreciated.
...
|
by: Thomas Due |
last post by:
Hi,
I am writing an ASP.NET project where I allow users to upload files to
the server. I have changed to web.config to allow a total file size of
100MB. My problem is that if the total file size...
|
by: Al Smith |
last post by:
I need help in implementing proper error handling.
I am trying to upload a file based on the sample code below. The code works
well except if the file selected is too big.
I do know about the...
|
by: Paul |
last post by:
Hi there,
When adding a "File Field" HTML control to an aspx page to facilitate file
uploading, the following occurs:
1. You select a file that is larger than the allowed size limit.
2. Once...
| |
by: tshad |
last post by:
I have an upload file input as:
<input id="MyFile" style="width:300px" type="File" runat="Server">
This works fine, but I find that if my page doesn't pass validation during
postback, the page...
|
by: jf li |
last post by:
I have a Asp.net web application and a Asp.net Web service application. The
Web application is using HtmlInputFile to get a 50M size of file selected by
end user, read the data of this file and...
|
by: Jim Michaels |
last post by:
after a file upload, $_FILES is not populated but $_POST is. what's going
on here?
$_POST=C
$_POST=C
$_POST=C
$_POST=C:\\www\\jimm\\images\\bg1.jpg
$_FILES=
$_FILES=
$_FILES=
|
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,...
|
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...
|
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...
| |
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: 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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |