resize an image and upload it to server
resize an image and upload it to server
Collapse
X
-
Tags: None
-
yes
the code is
[code=php]
<?php
$userfile_name= "image/terrest_gif.gif ";
$add="e:/$userfile_name" ; // the path with the file name where the file will be stored, upload is the directory name.
if(copy($userfi le_name, $add)){
echo "Successful ly uploaded the image";
chmod("$add",77 7);
}else
{
echo "Failed to upload file Contact Site admin to fix the problem";
exit;}
$n_width=100; // Fix the width of the thumb nail images
$n_height=100; // Fix the height of the thumb nail imaage
$tsrc="c:/$userfile_name" ; // Path where thumb nail image will be stored
if (!($userfile_ty pe =="image/pjpeg" OR $userfile_type= ="image/terrest_gif.gif "))
{
echo "Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
exit;
}
if (@$userfile_typ e=="image/terrest_gif.gif "){
$im=ImageCreate FromGIF($add);
echo "$im";
$width=ImageSx( $im);
echo "$width"; // Original picture width is stored
$height=ImageSy ($im);
echo $height; // Original picture height is stored
$newimage=image createtruecolor ($n_width,$n_he ight);
imageCopyResize d($newimage,$im ,0,0,0,0,$n_wid th,$n_height,$w idth,$height);
if (function_exist s("imagegif") ) {
Header("Content-type: image/gif");
ImageGIF($newim age,$tsrc);
}
elseif (function_exist s("imagejpeg" )) {
Header("Content-type: image/jpeg");
ImageJPEG($newi mage,$tsrc);
}
chmod("$tsrc",7 77);
if($userfile_ty pe=="image/pjpeg"){
$im=ImageCreate FromJPEG($add);
$width=ImageSx( $im); // Original picture width is stored
$height=ImageSy ($im); // Original picture height is stored
$newimage=image createtruecolor ($n_width,$n_he ight);
imageCopyResize d($newimage,$im ,0,0,0,0,$n_wid th,$n_height,$w idth,$height);
ImageJpeg($newi mage,$tsrc);
chmod("$tsrc",7 77);
}
}
?>
[/code]
Originally posted by pbmodsHeya, rinkudhimar.
Sure.
For $100.
Seriously now. You're going to have to give us more info than that.
Have you at least TRIED to implement it?Originally posted by AjaxrandFormat for the code tag is [CODE=language] [ / CODE]. not <code>. Full list of Code Tag Supported LanguagesComment
-
this forums awsome!! all i needed was a function to get image dimensions...go t a lot more than that....good work peopleComment
-
I am also expecting answers to my question and not such funny comments daily. I have sent the full code just because you get a detailed idea. Anyways I think that you cannot help at all.Comment
-
Comment