Reputation: 5238
Okay,
So I have a PHP file that uploads a image to my server. After uploading, I want to resize the image to a 100X100 file. Below is my code that doesn't work.
Please help!
<?php
include 'resize.image.class.php';
$get_username = "usernamehere";
$new_id = "19";
$uploadDir = "./../users/$get_username/pictures/";
$file = basename($_FILES['userfile']['name']);
$uploadFile = $file;
$newName = $uploadDir . $new_id . $uploadFile;
$file_size = $_FILES['userfile']['size'];
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
$image = new Resize_Image;
$image->new_width = 100;
$image->new_height = 100;
$image->image_to_resize = "./../users/$get_username/pictures/$new_id.jpg"; // Full Path to the file
$image->ratio = true;
$image->new_image_name = "$new_id";
$image->save_folder = "./../users/$get_username/pictures/thumbnails/";
$process = $image->resize();
}
?>
It's a simplified version. However, when I run the resize code separately, the code works. Thoughts?
Thanks again!
Upvotes: 0
Views: 830
Reputation: 46692
You are wrongly specifying the 'source' file name. The source file must be accessed by the temp_name thing. So, this line in your code is faulty:
$image->image_to_resize = "./../users/$get_username/pictures/$new_id.jpg";
Instead, do this:
$image->image_to_resize = $_FILES['userfile']['tmp_name'];
Upvotes: 1