IMAGE UPLOAD HELP - I already read the Tutorinal

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jaccrock
Forum Newbie
Posts: 17
Joined: Wed May 17, 2006 1:05 pm

IMAGE UPLOAD HELP - I already read the Tutorinal

Post by jaccrock »

Hi,

I'm working on a website where I need to upload digital camera pictures. I've been trying to follow the Tutorial for uploading and creating a thumbnail.

When I upload a test image of something small (7.14 KB), it works no problem.
When I uplaod a real image (2,116KB), I keep getting the following errors:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Warning: unlink(): No such file or directory in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 105

Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 107

Warning: imagesx(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 117

Warning: imagesy(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 117

Warning: imagesx(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 131

Warning: imagesy(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 132

Warning: imagecreatetruecolor(): Invalid image dimensions in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 134

Warning: imagesx(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 135

Warning: imagesy(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 135

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 135

Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 136
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

From what I can tell, they seem to deal with the $_FILES['image']['tmp_name'] variable.

So I ran a print out of if and $_FILES['image']['tmp_name'] is empty / blank.

Like I said, when I use the smaller image, it prints out the name of the tmp file no problem. Any ideas how to get this working?

Thanks!
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

you may be over the max filesize for uploads. Generally the default is only 2mb. To fix it you'll have to edit the php.ini to allow bigger uploads.
jaccrock
Forum Newbie
Posts: 17
Joined: Wed May 17, 2006 1:05 pm

Post by jaccrock »

if i'm using a webhost service, is there anything I can do?

I was even wondering if there is a javascript function i could run before uploaded it to my webhost server?

Any more ideas? Thanks!
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

no, if you dont have access to the webserver then you're pretty much screwed.
you could try and zip the image and send it like hopefully it will be under 2 mb


and what do you mean by "I was even wondering if there is a javascript function i could run before uploaded it to my webhost server? "
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

PrObLeM wrote:no, if you dont have access to the webserver then you're pretty much screwed. you could try and zip the image and send it like hopefully it will be under 2 mb
Actually, you can do this via an .htaccess file, I've run into this before.
Obviously your host has to allow the use of an .htaccess file...

PHP Manual: php.ini directives
PHP Manual: upload_max_filesize
PHP Manual: How to change configuration settings
jaccrock
Forum Newbie
Posts: 17
Joined: Wed May 17, 2006 1:05 pm

Post by jaccrock »

The javascript question was relating to resizeing the image small enough so that it will upload before sending it to the server... I've never done it, i don't even konw if it's possible? Just trying to throw out ideas


bdlang,

You said you ran into this before? How did you fix it? What can i do to the .htaccess file?


Thanks!
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

jaccrock wrote:The javascript question was relating to resizeing the image small enough so that it will upload before sending it to the server... I've never done it, i don't even konw if it's possible? Just trying to throw out ideas
javascript cant resize the file.
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

jaccrock wrote: bdlang,

You said you ran into this before? How did you fix it? What can i do to the .htaccess file?
My post has links to all the information you'll need in the PHP manual.
jaccrock
Forum Newbie
Posts: 17
Joined: Wed May 17, 2006 1:05 pm

Post by jaccrock »

i can't even use ini_set(), so i don't think those links will work for me. (getting disappointed with my webhost). I can't believe more peole haven't had problem like this before???
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Post by LiveFree »

I dont know how to do this...

But is there a flag in the .htacess you can enable to change the value of php.ini settings?
jaccrock
Forum Newbie
Posts: 17
Joined: Wed May 17, 2006 1:05 pm

Post by jaccrock »

it doesn't seem like i can even access the .htaccess file! ughh
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

  • Read the links I reference in my original post.
  • In your web root directory, create a file named .htaccess (note the '.')
  • The file should contain these lines:

    Code: Select all

    php_value upload_max_filesize 20971520
        php_value post_max_size 22020096
    (or whatever max file size you want)
  • Save the file
  • Don't forget to change the value of MAX_FILE_SIZE in your form.
  • Check your file upload script
Google search: .htaccess PHP
jaccrock
Forum Newbie
Posts: 17
Joined: Wed May 17, 2006 1:05 pm

Post by jaccrock »

THANK YOU! I (obviously) have limited experience with webhosts and I really appreciate the help! It WORKS
Post Reply