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

  • 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)
  • 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: Text File Transfer from a directory
    ... I am trying to make a dts pakage that will upload files from a directoy to a sql table. ... Its like i should be able to go through all files in a certain folder and upload those files to sql table... ...
    (microsoft.public.sqlserver.dts)
  • Re: Pass a parameter in sql statement with VB 2005...
    ... I get stuck on the line before ... WHERE FirstName = @fn", Con) ... are they only SQL server specific? ... Dim cmd As New SqlCommand("SELECT FirstName, ...
    (microsoft.public.dotnet.general)

Loading