"neo002244" <ne*******@hotmail.com> wrote in message
news:67*************************@posting.google.co m...
Randall,
Thanks for the reply. I am only putting the location of the image in
the database and not the image itself. I've noticed that only gif
images get corrupted, not jpegs. Isn't this strange behavior?
"Randell D." <yo**************************@yahoo.com> wrote in message
news:<mm***********************@news3.calgary.shaw .ca>...
"neo002244" <ne*******@hotmail.com> wrote in message
news:67**************************@posting.google.c om... The move_uploaded_file() function is very quirky. I want to allow
users to upload images to the Web site. Here is the code:
if(!move_uploaded_file($_FILES['tempimagefile']['tmp_name'],
$imagefile))
{
die("Could not move file: ".$_FILES['tempimagefile']['tmp_name']."
-> $imagefile");
} else {
enter record into database...
...
...
}
The record is added to the database, so I have to assume that the
move_uploaded_file() function returned a positive result. Elsewhere in
the Web site I have a function that displays the image. The
getimagesize() function is used to determine the image dimensions. I
get an error message when the move_uploaded_file() function had
corrupted the file upload:
Warning: getimagesize(): Read error! ...
Could not get size of: imagename.gif
The file exists but its size is 0 bytes. Somehow the image data is
non-existent. Only an empty file with the correct file name is
present. This causes the getimagesize() function to spew out that
error message. Is this a known issue with the move_uploaded_file()
function? I've read somewhere else that using the copy() function
results in the same thing - a corrupt file. Does anyone know why this
is happening? Is there any way to fix this problem? Thanks.
Are you storing the image as a disk file on disk or in your database?
(your conditional statement above says, after moving the image from tmp to
$imagefile you have something about 'enter record into database')... I'm
wondering if you're attempting to read the image from the db and that
could be the source of your problem.
I've never had problems uploading files of anysize (up to four or five
megabytes in size - perhaps larger). One are I did have problems though
was when I tested an upload from remote, I found my Linksys router that I
use as a firewall screwed up the file in transit (I've still not resolved this
problem). Files less than a meg were fine - anything larger were
unzippable/unreadable/undoable.
Dunno if that helps you out in anyway....
Someone in this newsgroup suggested that you should always reply to a post
by replying at the end of it - it makes it easier for others to read the
history by starting from the top (oldest thread) and paging down to the
newest thread... Just a suggestion, hope you don't mind...
anyway... its interesting that you say that you found the problem only
occurs for gifs and not jpgs - I'm wondering if you have a filesystem
problem - That might sound crazy but I've got the bones of about 2,500
images that I've saved over time - I burned them to disk and found I could
only read the jpgs - not the gifs... I then ftp'd the images from my linux
server to my windoze box and found again that I could not view the gifs
(though I had some of the originals on my windoze box and they could be
viewed so I could be sure the problem did not originate on my windoze box).
I've yet to find out the cause for this - but I suggest you try and ftp a
handful of images to your box and then try and view them... see if you get
the same problems and thus rule out the apache/php as the source of your
problem.
and just in case... I'm running SuSE Linux 7.1, kernal 2.4.0-4Gb (about a
year or more old)...