Trouble processing local files

See all posts Reply

Trouble processing local files new!
by Benjamin, 11 years, 10 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
Re: Trouble processing local files new!
by Benjamin, 11 years, 10 months ago
Sorry, ignore the bit about $newFilename - that was part of an attempt to prevent the duplicate file extension in the filenameReply
Re: Trouble processing local files new!
by Benjamin, 11 years, 10 months ago
Solved by removing $handle->clean();Reply