Welcome Guest, Not a member yet? Register   Sign In
image manipulation library
#1

[eluser]Ngulo[/eluser]
hi all,

i'm trying to resize uploaded images but it doesn't work for me this code:
Code:
$img = htmlentities($_FILES['logo']['name']);
                      $imgTemp =  htmlentities($_FILES['logo']['tmp_name']);

                       move_uploaded_file($postLogoTemp,'uploads/img/'.$img);
                      $config['image_library'] = 'gd2';
                      $config['source_image'] = 'uploads/img/'.$img;
                      $config['maintain_ratio'] = FALSE;
                      $config['width'] = 60;
                      $config['height'] = 60;

                      $this->load->library('image_lib', $config);

                      $this->image_lib->resize();
don't know why doesn't riseze me any uploaded image, he move images into my path but then doesn't risize,i don't think could be a path problem ,cause he move them so he have also to resize them by the same path,don't you think?

any suggestion?

really thanks guys

Wink
#2

[eluser]cahva[/eluser]
Where does $postLogoTemp come from in move_uploaded_file()? I think it should be $imgTemp. And dont use htmlentities with $_FILES['logo']['tmp_name']. So better would be:
Code:
$img = htmlentities($_FILES['logo']['name']);
move_uploaded_file($_FILES['logo']['tmp_name'],'uploads/img/'.$img);
#3

[eluser]pickupman[/eluser]
Why not use the upload class to handle the upload? There is also a function to sanitize the filename for security purposes.
Try using the full file path to the image.
Code:
$config['source_image'] = $_SERVER['DOCUMENT_ROOT'] . 'uploads/img/'.$img);

Or something similar based on your path.
#4

[eluser]Ngulo[/eluser]
@cahva

sorry man you're right at all!!
the code i post before is not right it is as shown:
Code:
$img = htmlentities($_FILES['logo']['name']);
$imgTemp =  htmlentities($_FILES['logo']['tmp_name']);
move_uploaded_file($imgTemp,'uploads/img/'.$img);
files are moved correctly, and is not this my problem for now :)

the fact is that the path to the image to resize() is right to...but he's still not resizing me images :/
a make an echo of $config['source_image'] = $_SERVER['DOCUMENT_ROOT'] . 'uploads/img/'.$img);
and then if i put this path into url i can see the image...but it is not resized() :/
#5

[eluser]pickupman[/eluser]
Maybe something minor, but from the user guide:
Quote:Note: In order for the image class to be allowed to do any processing, the image file must have "write" file permissions. For example, 777.

If you using your own upload method try using:
Code:
chmod($_SERVER['DOCUMENT_ROOT'] . 'uploads/img/'.$img, 0777);

Your file permission is probably 644 as a guess.
#6

[eluser]Ngulo[/eluser]
uhmm...... i'm on localhost could be this the main problem? :/
if i try using chmod i receive error message:
Message: chmod() [function.chmod]: No such file or directory

uhm....really strange :/
#7

[eluser]pickupman[/eluser]
are you on windows or on Linux? If you are on Linux, the file path must be off. On windows you quite need the same permissions as is either read only or writable. If you are on windows just make sure the folder permissions is set on users.
#8

[eluser]Ngulo[/eluser]
!!!! i fixed it!!!
the trick was this :/
$this->load->library('image_lib);
$this->image_lib->initialize($config);

thanks all guys anyway!!!!!! Wink
#9

[eluser]pickupman[/eluser]
Great...that's weird it wasn't taking the array as the second parameter. Most CI libraries take an array into the class constructor and call $this->initialize($config);
#10

[eluser]Ngulo[/eluser]
yes pickupman Wink
it was just to output a var_dump() and see Tongue

sorry Wink




Theme © iAndrew 2016 - Forum software by © MyBB