Reply to Re: Multiple processes

Re: Multiple processes new!
by colin, 17 years, 2 months ago
Do as on the example provided on the main page

$foo = new Upload($_FILES['form_field']); 
if ($foo->uploaded) {
  // save uploaded image with no changes
  $foo->Process('/home/user/files/');
  if ($foo->processed) { 
    echo 'original image copied'; 
  } else {
    echo 'error : ' . $foo->error;
  }
  // save uploaded image with a new name
  $foo->file_new_name_body = 'foo';
  $foo->Process('/home/user/files/');
  if ($foo->processed) {
    echo 'image renamed 'foo' copied';
  } else { 
    echo 'error : ' . $foo->error; 
  }
  // save uploaded image with a new name,
  // resized to 100px wide
  $foo->file_new_name_body = 'image_resized';
  $foo->image_resize = true;
  $foo->image_convert = gif;
  $foo->image_x = 100;
  $foo->image_ratio_y = true;
  $foo->Process('/home/user/files/');
  if ($foo->processed) {
    echo 'image renamed 'image resized', 
      resized x=100 and converted to GIF';
    $foo->Clean();
  } else {
    echo 'error : ' . $foo->error;
  }
}

So you instantiate the class, then call process() a first time. After the first processing is completed, the variables are reset, so you can set new resizing, etc... options. Then, call process() again.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