Re: PHP file upload unexpected error - file too large?

From: Erwin Moller (since_humans_read_this_I_am_spammed_too_much_at_spamyourself.com)
Date: 02/07/05


Date: Mon, 07 Feb 2005 15:02:39 +0100

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.



Relevant Pages

  • Re: Query to extract one record from multiple records
    ... whatever reason you are stuck with it, usually a sql answer will be ... although that assumes at least third normal form. ... can't do SQL, use PL/SQL. ... The merits of ansi versus oracle style join syntax ...
    (comp.databases.oracle.misc)
  • sql server not responding after building asp .net project
    ... I'm working on asp .net project,when trying to work in debug mode ... When I debuged it I saw it stuck when trying to connect to the sql ... I tried to reinstall the sql server, reinstall visual studio and .net ...
    (microsoft.public.sqlserver)
  • Sql server after building asp .net project
    ... I'm working on asp .net project,when i'm trying to work in debug ... When I debuged it I saw it stuck when trying to connect to the sql ... I tried to reinstall the sql server, reinstall visual studio and .net ...
    (microsoft.public.sqlserver)
  • Re: Query to extract one record from multiple records
    ... The correct answer is, of course, normalize your design. ... whatever reason you are stuck with it, usually a sql answer will be ... can't do SQL, use PL/SQL. ...  The merits of ansi versus oracle style join syntax ...
    (comp.databases.oracle.misc)
  • connection to sql server in debug mode is failed
    ... I'm working on asp .net project,when trying to work in debug mode ... When I debuged it I saw it stuck when trying to connect to the sql ... I tried to reinstall the sql server, reinstall visual studio and .net ...
    (microsoft.public.dotnet.framework.aspnet)