Welcome Guest, Not a member yet? Register   Sign In
uploading and using images
#12

[eluser]M4rc0[/eluser]
Yes please, I'm curious to check your code :d

I have one here that i got from php.net and adapted that does the following:
1) Get the file from the form file field
2) Create a resized copy from the original
3) Upload with a new name

So it doesn't need the path. I'm pasting the "secret" part of the code:
Code:
//get the $file parameter on the function
$tmp_image = imagecreatefromjpeg($file);

$width = imagesx($tmp_image);

$height = imagesy($tmp_image);

$new_image = imagecreatetruecolor($new_width,$new_height);

imagecopyresampled($new_image, $tmp_image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

//Grab new image
ob_start();

ImageJPEG($new_image);

$image_buffer = ob_get_contents();

ob_end_clean();

ImageDestroy($new_image);

//Create temporary file and write to it

$fp = tmpfile();

fwrite($fp, $image_buffer);

rewind($fp);
// now you can upload $fp with move_uploaded_file..

Considering you pass the correct paramaters (the file field) it works perfectly.

Although the code is good, i don't want to use it because i think it will be more trouble for me to adapt it than starting from zero.

Everything is working here exept it's not resizing the image.
After re-reading the image_lib documentation, i can't be sure of one thing: Is it possible to create a thumb AND resize the original image?

It is creating the thumb but it's not resizing. Why? Where do i pass the resizing width and height parameters?
Since the ones in $config are the width and height for the thumb.

Could you confirm me that textnotspeech ?

That would be my last try before adapating the code above Tongue


Messages In This Thread
uploading and using images - by El Forum - 09-14-2008, 08:24 AM
uploading and using images - by El Forum - 09-14-2008, 07:36 PM
uploading and using images - by El Forum - 09-16-2008, 01:51 PM
uploading and using images - by El Forum - 09-16-2008, 05:38 PM
uploading and using images - by El Forum - 09-17-2008, 03:00 AM
uploading and using images - by El Forum - 09-17-2008, 09:24 AM
uploading and using images - by El Forum - 09-17-2008, 09:39 AM
uploading and using images - by El Forum - 09-17-2008, 10:11 AM
uploading and using images - by El Forum - 09-17-2008, 10:55 AM
uploading and using images - by El Forum - 09-17-2008, 11:05 AM
uploading and using images - by El Forum - 09-17-2008, 11:19 AM
uploading and using images - by El Forum - 09-17-2008, 11:42 AM
uploading and using images - by El Forum - 09-17-2008, 12:16 PM
uploading and using images - by El Forum - 09-18-2008, 11:28 AM
uploading and using images - by El Forum - 09-19-2008, 06:20 AM
uploading and using images - by El Forum - 09-19-2008, 06:36 AM
uploading and using images - by El Forum - 09-19-2008, 06:38 AM
uploading and using images - by El Forum - 09-19-2008, 07:00 AM
uploading and using images - by El Forum - 09-19-2008, 07:08 AM
uploading and using images - by El Forum - 09-19-2008, 07:09 AM
uploading and using images - by El Forum - 09-19-2008, 07:11 AM
uploading and using images - by El Forum - 09-19-2008, 07:12 AM
uploading and using images - by El Forum - 09-19-2008, 07:19 AM
uploading and using images - by El Forum - 09-19-2008, 07:21 AM
uploading and using images - by El Forum - 09-19-2008, 09:13 AM
uploading and using images - by El Forum - 09-20-2008, 12:54 PM
uploading and using images - by El Forum - 09-20-2008, 02:46 PM
uploading and using images - by El Forum - 09-20-2008, 03:11 PM
uploading and using images - by El Forum - 09-20-2008, 03:28 PM
uploading and using images - by El Forum - 09-20-2008, 03:59 PM
uploading and using images - by El Forum - 09-20-2008, 04:10 PM
uploading and using images - by El Forum - 09-20-2008, 04:32 PM
uploading and using images - by El Forum - 09-20-2008, 05:41 PM
uploading and using images - by El Forum - 09-22-2008, 01:35 PM
uploading and using images - by El Forum - 09-22-2008, 01:59 PM
uploading and using images - by El Forum - 09-22-2008, 02:01 PM
uploading and using images - by El Forum - 09-23-2008, 02:57 AM
uploading and using images - by El Forum - 09-23-2008, 03:02 AM
uploading and using images - by El Forum - 09-23-2008, 03:19 AM
uploading and using images - by El Forum - 09-23-2008, 03:24 AM
uploading and using images - by El Forum - 09-23-2008, 03:38 AM
uploading and using images - by El Forum - 09-23-2008, 03:47 AM
uploading and using images - by El Forum - 09-23-2008, 04:16 AM
uploading and using images - by El Forum - 09-23-2008, 04:21 AM
uploading and using images - by El Forum - 09-23-2008, 10:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB