class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
I am trying to process a local file with the following code. It returns successfully but seems to be deleting the file after it is processed (vanishes from the file system). I attempted to add $handle0>new_name_body = $filename but this results in a file with the filename 'foo_bar.jpg.jpg' (for example).
I am trying to process a local file with the following code. It returns successfully but seems to be deleting the file after it is processed (vanishes from the file system). I attempted to add $handle0>new_name_body = $filename but this results in a file with the filename 'foo_bar.jpg.jpg' (for example).
What am I doing wrong? -
$filename = $_POST['filename']; $path = $_SERVER['DOCUMENT_ROOT'] . '/files/'; $file = $path . $filename; $newFilename = str_replace('.jpg', '', $filename); $handle = new upload($file); $handle->file_overwrite = true; $handle->file_auto_rename = false; $handle->image_resize = true; if ($handle->image_src_x > $handle->image_src_y) { $handle->image_x = 320; $handle->image_y = 240; } else { $handle->image_x = 240; $handle->image_y = 320; } $handle->image_ratio = true; $handle->process($path); if ($handle->processed) { echo $newFilename; $handle->clean(); } else { echo 'error : ' . $handle->error; echo $file; }