Pure PHP Upload 2 Support Product Page

Pure upload that allows own resize script?

Shared 05 Dec 2009 12:10:45
1
likes this idea
05 Dec 2009 12:10:45 student 101 posted:
Pure upload should allow me to add my own resize image script, where could I add it in PUP?
In any one of these files?
QuoteincPureUpload.js, incPureUpload.php

I could use the already added code?
function setThumbFileName($newFileName, $path, $naming, $suffix) {
    $this->thumbFileName = $newFileName;
    $this->thumbPath = $path;
    $this->thumbNaming = $naming;
    $this->thumbSuffix = $suffix;
    $this->thumbName = substr($newFileName, 0, strrpos($newFileName, '.'));
    $this->thumbExtension = substr($newFileName, strrpos($newFileName, '.')+1);
    if (file_exists($path."/".$this->thumbFileName)) {
      $this->thumbSize = round((filesize($path."/".$this->thumbFileName)/1024), 0);
    }
    $this->upload->uploadedFiles[$this->field] = $this;
  }

  function setThumbSize($width, $height) {
    $this->thumbWidth = $width;
    $this->thumbHeight = $height;
    $this->upload->uploadedFiles[$this->field] = $this;
  }

  function setImageSize($width, $height) {
    $this->imageWidth = $width;
    $this->imageHeight = $height;
    $this->upload->uploadedFiles[$this->field] = $this;
  }

Replies

Replied 11 Dec 2009 16:57:40
11 Dec 2009 16:57:40 Patrick Julicher replied:
Hi Json,

I also added your request for using own resize code to the wish list for future updates.

Kind regards, Patrick
Replied 11 Dec 2009 17:45:48
11 Dec 2009 17:45:48 student 101 replied:
QuoteHi Json,
I also added your request for using own resize code to the wish list for future updates.
Kind regards, Patrick

That's cool. []
Thanks! []
Replied 02 Apr 2010 00:53:28
02 Apr 2010 00:53:28 student 101 replied:
Quoteadded your request for using own resize code to the wish list for future updates.

Hi Patric,

Where do I look in the PHP upload script?
Replied 06 Apr 2010 12:26:46
06 Apr 2010 12:26:46 Patrick Woldberg replied:
You can always add your own resize image script, should work. Place it after the Pure Upload class, then you are sure the file is at the location you uploaded and you can do whatever you want with the file. The function your showing from the Pure Upload aren't needed unless you also have some other extensions that rely on Pure Upload, then you can use those function to set the correct values so the other extensions can find the files.
Replied 06 Apr 2010 17:58:34
06 Apr 2010 17:58:34 student 101 replied:
QuoteYou can always add your own resize image script, should work. Place it after the Pure Upload class, then you are sure the file is at the location you uploaded and you can do whatever you want with the file.

At the end of class pureFileUpload
Quote
function getThumbFileName() {
return $this->thumbFileName;
}
}

// ...
// add resize code here?

or the end of $ppu->doUpload();
Replied 23 Jul 2010 10:52:18
23 Jul 2010 10:52:18 student 101 replied:
QuoteYou can always add your own resize image script, should work.

My resize script works, as soon as I add the PHP Upload my resize code stops working?
Quote<?php
// Config
$uploaddir = "resize/";
if (!is_dir("resize" ) ) {
if (!mkdir($uploaddir) )
die ("upload_files directory doesn't exist and creation failed" ) ;
if (!chmod($uploaddir,0755) )
die ("change permission to 755 failed." ) ;
}
if(isset($_POST['upload']) ) {
$image_name = $_FILES['file']['tmp_name'];
$new_side = 100;
// New dimensions
list($width, $height) = getimagesize($image_name);
$w = $width;
$h = $height;
if ($h > $w) {
$new_width = ($new_side / $h) * $w;
$new_height = $new_side;
} else {
$new_height = ($new_side / $w) * $h;
$new_width = $new_side;
}

$image_p = imagecreatetruecolor($new_width, $new_height) ;
$image = imagecreatefromjpeg($image_name) ;
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height) ;
$upload_image = $_FILES['file']['name'] ;
imagejpeg($image_p, "$uploaddir$upload_image" ) ;
} // end resize...

$handle=opendir($uploaddir);
$filelist = "";
$pattern="(\.jpg$|\.jpeg$|\.gif$)"; //valid image extensions
while ($file = readdir($handle) ) {
if(!is_dir($file) &&!is_link($file) ) {
if(eregi($pattern, $file)) {
$filelist .= "<img src='$uploaddir$file'>";
$filelist .="<br>";
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Resize Image</title>
</head>
<body>
<form action="resize.php" method="post" ENCTYPE="multipart/form-data">
File: <input type="file" name="file" size="30">
<input type="submit" name="upload" value="Upload!">
</form>
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr><td><p><?php echo $filelist; ?></p></td>
</tr><tr><td>&nbsp;</td>
</tr><tr><td>&nbsp;</td></tr>
</table>

</body>
</html>
Replied 01 Dec 2022 16:22:45
01 Dec 2022 16:22:45 Akice Moore replied:
Are you in need of a resume makeover? Look no further! We have all the tools and resources you need to create a winning resume. Check out our blog for tips on resume writing, using resume examples and references on resume example, and more! Get the resume you deserve - start now!

Reply to this topic