force download

See all posts See thread Reply

Re: force download new!
by colin, 5 years, 3 months ago
You don't have any image modification in your code above.

Anyhow, you can check the logs to see what's going on.Reply
Re: force download new!
by ray, 5 years, 3 months ago
Sorry, miss communication
i mean, i use code base on that code, but not working.

here my code
include('lib/class.upload.php');
$file = "image.jpg";
$files = "new-image.jpg";

$handle = new upload($file);
if ($handle->uploaded) {
 if ($handle->processed) {
	$handle->file_new_name_body   = $files;
	$handle->image_resize         = true;
	$handle->image_y              = 400;
	$handle->image_ratio_x        = true;
	header('Content-Type: application/octet-stream');
	header('Content-Disposition: attachment; filename='.basename($files));		
	$handle->process("$file");					
	echo $handle->Process();
	die();		
	
  } else {
	echo 'error : ' . $handle->error;
 }
}

that code download same image as original without modification.Reply
Re: force download new!
by colin, 5 years, 3 months ago
Check the log produced by the class.Reply
Re: force download new!
by ray, 5 years, 3 months ago
it's not produce any error log
I just create that one page only, load image from local file, not upload file. and modified with that amazing class.

i just create that one page, and running to tested force download.

or maybe i miss something?Reply
Re: force download new!
by colin, 5 years, 3 months ago
I just noticed, your code is incorrect, you call process() twice, and wrongly check on processed too soon. Try this:

include('lib/class.upload.php');
$file = "image.jpg";
$files = "new-image.jpg";

$handle = new upload($file);
if ($handle->uploaded) {
  $handle->file_new_name_body   = $files;
  $handle->image_resize         = true;
  $handle->image_y              = 400;
  $handle->image_ratio_x        = true;
  header('Content-Type: application/octet-stream');
  header('Content-Disposition: attachment; filename='.basename($files));						
  echo $handle->process();
  die();		
} else {
  echo 'error : ' . $handle->error;
}
Reply
Re: force download new!
by ray, 5 years, 3 months ago
I Do this before, and it's create no image, i mean image with nothing to display.Reply
Re: force download new!
by colin, 5 years, 3 months ago
I am afraid you need to try harder. Instead of outputing the image in the browser, try first to output it on disk, and check the logs produced by the class (output $handle->log). Once it works on disk, output the image in the browserReply
Re: force download new!
by ray, 5 years, 3 months ago
Okay, i will try
thanks for your support, i will update when success.

anyway.. you create great class upload, i use in other handle and it's amazing.

thanks
RayReply
Re: force download new!
by ray, 5 years, 3 months ago
also, there is no open any page when i do force download.Reply