Page 1 of 1

resize image with PHP

Posted: Fri Aug 17, 2007 10:56 am
by lammspillning
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I've been stucked with this problem for a while now and cant get it to work..

I have a code that upload and renames a image. 
Now I want that image to be resized to 700*525 pixels, and overwrite the big uploaded image with the small resized image.
I have tested many examples I found, but I dont get it to work..

this is the code I have to upload and rename the image, can someone [s]plz[/s] [size=150][color=green]please[/color][/size] show me the code that is needed and where to put it in my existing code..//[s]thnx[/s] [size=150][color=green]thanks[/color][/size]

Code: Select all

<?php
//create the directory if doesn't exists (should have write permissons)
if(!is_dir("./files")) mkdir("./files", 0755); 

//move the uploaded file
move_uploaded_file($_FILES['Filedata']['tmp_name'], "MY_IMG.jpg");

?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]11.[/b] Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.[/quote]

Re: resize image with PHP

Posted: Fri Aug 17, 2007 11:13 am
by superdezign
lammspillning wrote:this is the code I have to upload and rename the image, can someone plz show me the code that is needed and where to put it in my existing code..//thnx
You're asking for too much.
Look into the GD library, specifically imagecopyresize() and imagecopyresample()

Posted: Fri Aug 17, 2007 11:36 am
by lammspillning
ok sorry, I know I'm asking for much.. I'ts just that I tried to paste example code a number of times and never get it to work..
//thanx anyway

Posted: Fri Aug 17, 2007 11:40 am
by superdezign
lammspillning wrote:I'ts just that I tried to paste example code a number of times and never get it to work..
Which is why you need to make sure you understand the code instead of pasting it... Exactly the reason why I didn't just give you a snippet. If you don't understand it, you don't learn it, and your cripple yourself. Take the time and effort to understand what works and why.

Posted: Fri Aug 17, 2007 1:32 pm
by John Cartwright
At minimum, show us what you have tried.