Welcome Guest, Not a member yet? Register   Sign In
Using Image_moo with uploadify
#1

[eluser]trinic[/eluser]
I have this file(uploadify.php):

Code:
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = dirname(__FILE__).'/../'. trim($_REQUEST['folder'], '/') . '/';
$dateForUnique = time();
$myfilename = preg_replace('/[^A-Za-z0-9_]/', "", $tempFile );
// get the first char of the tagetfile name, and, make sure we move it into the
  // correct sub directory too (for vcdb)
$randHex = substr(md5(rand()), 0, 16);
  if (strstr($targetPath,'vcdbuploads')) {
      $firstChar = substr($randHex,0,1);
      $targetPath .= $firstChar . '/';
  }
  //echo($targetPath."\n\n");
//$myLocation = $dateForUnique . $_FILES['Filedata'] .
$dateForUnique = $randHex . $dateForUnique;
$targetFile =  str_replace('//','/',$targetPath) . $dateForUnique . $myfilename;
$myarray = array("location"=> $dateForUnique . $myfilename);
$mynameext = explode(".",$_FILES['Filedata']['name']);
$mynameext = end($mynameext);
$targetFile .= "." . $mynameext;
// $fileTypes  = str_replace('*.','',$_REQUEST['fileext']);
// $fileTypes  = str_replace(';','|',$fileTypes);
// $typesArray = split('\|',$fileTypes);
// $fileParts  = pathinfo($_FILES['Filedata']['name']);

// if (in_array($fileParts['extension'],$typesArray)) {
  // Uncomment the following line if you want to make the directory if it doesn't exist
  // mkdir(str_replace('//','/',$targetPath), 0755, true);
  //echo($targetFile);

  //print_r($_FILES);
  //echo "\n<testte>\n";
  //echo $tempFile;
  //echo "\n<test>\n";
  //echo $targetFile;
  //echo "\n<test>\n";

  move_uploaded_file($tempFile,$targetFile);

  //echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
  //echo json_encode($myarray);
  echo($dateForUnique.$myfilename.'.'.$mynameext);
// } else {
//  echo 'Invalid file type.';
// }

}
?&gt;

I'm wanting to add the bit of image moo code that crop_rotates an image and save it in to a thumbnail. Where would I put the image moo code to do that? I tried to put it at the bottom and caught http errors
#2

[eluser]trinic[/eluser]
This is the function that gets the image in my controller.

Code:
public function photos_get($id)
{
     $photos = '';
     $intellPhotos = $this->intell_model->getIntellPhotos($id);
     foreach ($intellPhotos as $p) {
  $photos .= '<div>';
  $photos .= '<div class="photodelete" id="photo_' . $p-&gt;id . '">[ X ]</div><br />';
  $photos .= '<img src="' . base_url() . 'intelluploads/' . $p-&gt;location . '" height="100" />';
  $photos .= '</div>';
     }
     $photos .= '<div class="clear"></div>';
     echo($photos);
}

What i'm trying to do is have a thumbnail image created and have the thumb_ prefix on it so I can just use the same filename, etc, with the prefix to display the thumbnails.
#3

[eluser]Mat-Moo[/eluser]
After you move_uploaded_file - $this->image_moo->load($targetFile)->crop...etc.




Theme © iAndrew 2016 - Forum software by © MyBB