Jump to content

Upload help


cip6791

Recommended Posts

<?php

 

//

//## You can find the configuration after the resizeimage function... ##

//

function resizeimage($imgurl,$maxw,$maxh,$orx,$ory,$itype,$succes){

$tmpimg = @imagecreatetruecolor($maxw,$maxh);

if ($itype==1) {

if (function_exists("imagegif")) {

$initial = imagecreatefromgif($imgurl);

if (imagecopyresized($tmpimg,$initial,0,0,0,0,$maxw,$maxh,$orx,$ory)==1) {

imagegif($tmpimg,$imgurl,100);

imagedestroy($tmpimg);

imagedestroy($initial);

@header("Location: ".$succes);

exit;

} else {

unlink($imgurl);

}} else {

unlink($imgurl);

echo('<B>EROARE</B>: Nu exista functia  <I>imagegif()</I>!');

exit;

};

} else {

$initial = imagecreatefromjpeg($imgurl);

if (imagecopyresized($tmpimg,$initial,0,0,0,0,$maxw,$maxh,$orx,$ory)==1) {

imagejpeg($tmpimg,$imgurl,100);

imagedestroy($tmpimg);

imagedestroy($initial);

@header("Location: ".$succes);

exit;

} else {

unlink($imgurl);

}

}

}

// ## CONFIGURATION STARTS HERE: ##

 

$directorfisieregif='gifs/'; // ## .gif file directory here ##

$directorfisierejpg='jpgs/'; // ## .jpg file directory here ##

$resize=1;                  // ## 1=true,0=false. If true then file resizing will be enabled. ##

$maxx=1024;                  //## max width of a file ##

$maxy=768;                  // ##max height of a file ##

$pagupload='html/uploadform.html'; //## this is the redirection the your uploadform ##

$pagdupapost='index.php'; //## this is the redirection after a succesfully upload of a file ##

$pagrongrez='html/rongrez.html'; //## redirection in case of rong rezolution(only if resize disabled) ##

$pageexists='html/exists.html'; //## redirection if file allready exists on server ##

$pageview='index.php';      // ## this is the script for thumbnails creation ##

 

// ## CONFIGURATION ENDS HERE ##

 

$actiune=trim($_GET['do']);

if ($actiune=="") {@header("Location: http://www.sportnonstop.net");} else

if ($actiune=="upload"){

if ($_FILES['userfile']['type'] == 'image/gif'){

if (file_exists($directorfisieregif.$_FILES['userfile']['name']))

{@header("Location: ".$pageexists); exit;}

@move_uploaded_file($_FILES['userfile']['tmp_name'],$directorfisieregif.$_FILES['userfile']['name']);

$result=$directorfisieregif.$_FILES['userfile']['name'];

$imgtype=1;

} else

if ($_FILES['userfile']['type'] == 'image/pjpeg'){

if (file_exists($directorfisierejpg.$_FILES['userfile']['name']))

{@header("Location: ".$pageexists); exit;}

@move_uploaded_file($_FILES['userfile']['tmp_name'],$directorfisierejpg.$_FILES['userfile']['name']);

$result=$directorfisierejpg.$_FILES['userfile']['name'];

$imgtype=2;

} else {exit;};

list($width, $height, $type, $attr)= getimagesize($result);

if ($width<$maxx){@header("Location: ".$pagdupapost);

exit;

} else if ($width>$maxx) {

if ($resize==1) { resizeimage($result,$maxx,$maxy,$width,$height,$imgtype,$pagdupapost);} else

{

@header("Location: ".$pagrongrez);

unlink($result);

exit;

}

}

else {

if ($height<$maxy){@header("Location: ".$pagdupapost);

exit;

} else if ($height>$maxy) {

if ($resize==1) { resizeimage($result,$maxx,$maxy,$width,$height,$imgtype,$pagdupapost);} else

{

@header("Location: ".$pagrongrez);

unlink($result);

exit;

}

}}

} else if ($actiune=="uploadform") {@header("Location: ".$pagupload);

} else if ($actiune=="viewform") {@header("Location: ".$pageview);};

?>

Link to comment
https://forums.phpfreaks.com/topic/47104-upload-help/#findComment-229730
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.