1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
require_once("../codelibrary/inc/variables.php");
if (!empty($_FILES)) {
$tp = microtime();
$tempFile =$_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
$targetFile = $targetPath .substr($_FILES['Filedata']['name'], 0, -4).$tp.strtolower(substr($targetFile, -4));
$segment = array();
$variable = $_GET['variable'];
$tock = strtok($variable, "/");
while ($tock != false)
{
array_push($segment,$tock);
$tock = strtok("/");
}
$rqt=mysql_query('INSERT INTO ....');
if(!$rqt){
$ALERT = "errorr";
}
move_uploaded_file($tempFile,$targetFile);
$imgsize = getimagesize($targetFile);
switch(strtolower(substr($targetFile, -3)))
{
case "jpg":
$image = imagecreatefromjpeg($targetFile);
break;
case "png":
$image = imagecreatefrompng($targetFile);
break;
case "gif":
$image = imagecreatefromgif($targetFile);
break;
default:
exit;
break;
}
$width = 100; //New width of image
$height = $imgsize[1]/$imgsize[0]*$width; //This maintains proportions
$src_w = $imgsize[0];
$src_h = $imgsize[1];
$picture = imagecreatetruecolor($width, $height);
imagealphablending($picture, false);
imagesavealpha($picture, true);
$bool = imagecopyresampled($picture, $image, 0, 0, 0, 0, $width, $height, $src_w, $src_h);
if($bool){
switch(strtolower(substr($targetFile, -3))){
case "jpg":
header("Content-Type: image/jpeg");
$bool2 = imagejpeg($picture,$targetPath."Thumb/".substr($_FILES['Filedata']['name'], 0, -4).$tp.strtolower(substr($targetFile, -4)) ,80);
break;
case "png":
header("Content-Type: image/png");
imagepng($picture,$targetPath."Thumbs/".substr($_FILES['Filedata']['name'], 0, -4).$tp.strtolower(substr($targetFile, -4)));
break;
case "gif":
header("Content-Type: image/gif");
imagegif($picture,$targetPath."Thumb/".substr($_FILES['Filedata']['name'], 0, -4).$tp.strtolower(substr($targetFile, -4)));
break;
}
}
} |
Partager