Upload Images, Creating Thumbnails and add them to database

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
admin2gd1
Forum Newbie
Posts: 15
Joined: Fri Aug 15, 2008 2:21 pm

Upload Images, Creating Thumbnails and add them to database

Post by admin2gd1 »

I have been creating a upload form for images that creates a thumbnail and a resized image and placing them in to seperate locations.

I have succesfully done this for 1 image without inserting the image into a database.

Now I am trying to upload 12 images and resize at the same time and insert them into the database where it updates the rows where the photo goes.

So I have these following errors that I have not managed to get round to work.

1. The photos I do not think are being picked up from the form correctly for each image.
2. The images will not create a thumbnail for each image.
3. The process thinks that the image is not valid even if the first 2 errors were actually working.
4. Because of error 1, 2 and 3 the photo is uploading into the directories for each image and type (original, resized and thumbnail)
5. Because of the first 4 errors, it doesn't update the database for the ID number in the table specified for the date for last edit.

I have uploaded the first stage with just a basic form to create the images and the 2 seperated pages for creating the images and adding them to the database.

If I can have some help on correct these errors I would really appreciate it.

Thank you.

P.S. When the form checks if the file size has gone over the limit, the image files are still uploaded to the directories specified so that needs fixing also.
Attachments
upload img and show thumb.zip
(5.88 KiB) Downloaded 8 times
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Upload Images, Creating Thumbnails and add them to database

Post by josh »

admin2gd1 wrote:1. The photos I do not think are being picked up from the form correctly for each image.
print_r( $_FILES );
2. The images will not create a thumbnail for each image.
an image is a file, its not going to create anything.. you have to write code to do that
3. The process thinks that the image is not valid even if the first 2 errors were actually working.
you should learn about error / exception handling, in my opinion so you can gracefully handle unexpected program events.
4. Because of error 1, 2 and 3 the photo is uploading into the directories for each image and type (original, resized and thumbnail)
right, cuz you didnt tell the code to check if the photo is valid
5. Because of the first 4 errors, it doesn't update the database for the ID number in the table specified for the date for last edit.
that would make sense
P.S. When the form checks if the file size has gone over the limit, the image files are still uploaded to the directories specified so that needs fixing also.
I hope you don't expect anyone to do that for you

Also this may be helpful http://us2.php.net/features.file-upload
Post Reply