Forum Home
Press F1
 
Thread ID: 61263 2005-08-30 06:04:00 PHP - resize pictures on submission Morgenmuffel (187) Press F1
Post ID Timestamp Content User
1357359 2005-08-30 06:04:00 Tools being Used
PHP, Mysql, Dreamweaver

2 Questions


Sorry in advance, this made sense in my head but somewhere between brain and keyboard the meaning becomes a little muddied, hope it makes sense now

Question 1

I am designing a site with heaps of products,

normally I put up a thumbnail size image and a bigger image, so that when you click on the thumbnail the bigger image is displayed,

How do i do this so that instead of putting 2 images up (the thumbnail and the bigger picture), I just put up the bigger image and the thumbnail is automatically generated,

This site is probably going to get a lot of traffic, so would prefer a way that actually creates the thumbnail and saves it on the server when it is first put up, rather than one that creates the thumbnail everytime a user goes to the page it happens to be on (does that make sense)

Question 2

And i also need to know how to actually select an image off my harddive to put to the server (currently use ftp), I want to be able to do this through a webpage, you know the type of thing
It brings up the windows explorer box and you navigate to a directory and select the file, and it then uploads it on to the server

If you need me to explain something clearer let me know, and I will try

As usual any help will be greatly appreciated

Cheers Nigel
Morgenmuffel (187)
1357360 2005-08-30 06:26:00 Hey nigel,

Makes sense to me.

Q 1: This is only possible if you have access to the server, in which you are able to execute commands on server itself. There are many utilities on Unix/Linux that are capable of this, one would be provided by ImageMagick like Mogrify. Other than this, I don't know of any other way you could do this, unless the graphics library with PHP is powerful enough for doing such a task.

Option 2: This is pretty standard HTML, where you use type="file", I'm sure you can find an answer to this, also remember the <form> tag must contain enctype="multipart/form-data" and method="post". Just create your PHP script to handle the processing of it.


Cheers,


KK
Kame (312)
1357361 2005-08-30 07:01:00 The GD Graphics Library will handle this with ease
You'll have check what version of the GD Graphics Library is installed on your server
It will need to be version 2 or higher
bartsdadhomer (80)
1357362 2005-08-30 07:04:00 Thanks Kame

I found a way to do the first part of my query at codewalkers,
codewalkers.com
You mentioning the php graphics library kicked my brain into gear

as for the second part i will use what you've given me to start searching, thats normally my problem I don't know the correct thingie to serch for and end up with lots of less than useful stuff

Thanks again
Morgenmuffel (187)
1357363 2005-08-30 07:30:00 Whoops

Thanks Bartsdadhomer

I just checked that seems all systems are go

below is the info from a phpinfo() on the server

GD Support enabled
GD Version bundled (2.0.28 compatible)
FreeType Support enabled
FreeType Linkage with freetype
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled

so hopefully should all work

Cheers
Morgenmuffel (187)
1357364 2005-08-31 07:21:00 Ok I have a problem I ' m getting the following error when I try uploading the image




Return Code: 0
Uploading menu_top . gif (image/gif, 1 Kb) .
File is temporarily stored as /tmp/phpdv5Ieq
Warning: move_uploaded_file(uploads/menu_top . gif): failed to open stream: Permission denied in /home/nigelge/public_html/upload . php on line 25

Warning: move_uploaded_file(): Unable to move ' /tmp/phpdv5Ieq ' to ' uploads/menu_top . gif ' in /home/nigelge/public_html/upload . php on line 25
File has been stored in your uploads directory


And yes i have an uploads directory



<?php
if (($_FILES[ ' file ' ][ ' type ' ] == ' image/gif ' ) &&
($_FILES[ ' file ' ][ ' size ' ] < 5000))
{
echo ' Return Code: ' . $_FILES[ ' file ' ][ ' error ' ] . ' <br /> ' ;
echo ' Uploading ' . $_FILES[ ' file ' ][ ' name ' ] . ' ( ' .
$_FILES[ ' file ' ][ ' type ' ] . ' , ' .
ceil($_FILES[ ' file ' ][ ' size ' ] / 1024) . ' Kb) . <br /> ' ;
echo "File is temporarily stored as " . $_FILES["file"]["tmp_name"];

if (file_exists( ' uploads/ ' . $_FILES[ ' file ' ][ ' name ' ]))
{
echo $_FILES[ ' file ' ][ ' name ' ] . ' already exists . ' ;
echo ' Please delete the destination file and try again . ' ;
}
else
{
move_uploaded_file($_FILES[ ' file ' ][ ' tmp_name ' ], ' uploads/ ' . $_FILES[ ' file ' ][ ' name ' ]);


echo ' File has been stored in your uploads directory . ' ;
}
} else
{
echo ' Sorry, we only accept . gif images under 5Kb for upload . ' ;
}
?>



Any help would be appreciated
Morgenmuffel (187)
1357365 2005-08-31 09:22:00 CHMOD? sal (67)
1357366 2005-08-31 11:23:00 I'm inclined to agree with sal
Have you configured directory permissions correctly
bartsdadhomer (80)
1357367 2005-08-31 23:17:00 Thanks

It was a permissions error, I feel bloody stupid now,
Morgenmuffel (187)
1357368 2005-09-01 00:01:00 Thanks

It was a permissions error, I feel bloody stupid now,
In that case I've felt stupid many times :D
bartsdadhomer (80)
1 2 3 4