Reply to Trouble processing local files

Trouble processing local files new!
by Benjamin, 12 years, 4 months ago
Greetings,

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;
}
Reply

Your reply

Name *
Email 
Title *
Text *
CAPTCHA image
Enter the code displayed on the image:
Click on the image to generate another one if it is hard to read it. The case is important