|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
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: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: |
<$php
function upload_resize_images($xxx,$imageSize, $st_imgfile,$destroy_original)
{
$abpath = "/home/goldlogs/public_html/".$st_imgfile; //Absolute path to where images are uploaded. No trailing slash
$sizelim = "no";
$size = "2500000";
//all image types to upload
$cert[1]="image/pjpeg"; //Jpeg type 1
$cert[2]="image/jpeg"; //Jpeg type 2
$cert[3]="image/gif"; //Gif type
$cert[5]="image/png"; //Png type
$cert[18]="image/jpg";
$cert[19]="image/x-png";
$log .= ($_FILES[$xxx]['name'] == "") ? "No file selected for upload $xxx<br>":"";
if ($_FILES[$xxx]['name'] != "")
{
//checks if file exists
if (file_exists("$abpath/".$_FILES[$xxx]['name']) AND $destroy_original=="no")
{ $log .= "File $xxx already existed<br>";
}
else
{
//checks if files to big
if ($sizelim == "yes") {
$log .= ($_FILES[$xxx]['size'] > $size) ? "File $xxx was too big<br>":"";
}
set_time_limit(90); // resets timeout to 60 seconds on each send
//Checks if file is an image
if (array_search($_FILES[$xxx]['type'], $cert))
{
$imgfilename=str_replace(" ","_",$_FILES[$xxx]['name']);
if($destroy_original=="no"){
@move_uploaded_file($_FILES[$xxx]['tmp_name'],$abpath."/".$imgfilename) or $log .= "Couldn't copy image $xxx to server<br>";
}
$log .= (file_exists("$abpath/".$imgfilename)) ? "File $xxx was uploaded<br>" : "";
// create thumbnail and resize
$OriginalImage = null;
if ($_FILES[$xxx]['type']== $cert[1] OR $_FILES[$xxx]['type']== $cert[2] OR $_FILES[$xxx]['type']== $cert[18] ) {
$OriginalImage = imagecreatefromjpeg("$abpath/".$imgfilename);
} else if ($_FILES[$xxx]['type']== $cert[5] OR $_FILES[$xxx]['type']== $cert[19] ) {
$OriginalImage = imagecreatefrompng("$abpath/".$imgfilename);
} else if ($_FILES[$xxx]['type']== $cert[3] ) { $OriginalImage = imagecreatefromgif("$abpath/".$imgfilename);
} else if ($_FILES[$xxx]['type']== $cert[7] OR $_FILES[$xxx]['type']== $cert[8] ) {
$OriginalImage = imagecreatefromwbmp("$abpath/".$imgfilename);
}
else{
$image_failure_flag=1;
}
if(!$image_failure_flag){
$OriginalSize = getimagesize("$abpath/".$imgfilename);
$OriginalWidth = $OriginalSize[0];
$OriginalHeight = $OriginalSize[1];
$scale1 = min($imageSize/$OriginalWidth, $imageSize/$OriginalHeight);
$new_width1= floor($scale1*$OriginalWidth);
# Create a new temporary image
$tmp_img1 = imagecreatetruecolor($new_width1, $new_height1);
// change the background to white for transparent images
$ImgWhite1=imagecolorallocate($tmp_img1,255,255,255);
// $ImgWhite1=imagecolorallocate($tmp_img1,$img_bkgd1[r],$img_bkgd1[g],$img_bkgd1[b]);
imagefill($tmp_img1, 0,0, $ImgWhite1);// create white background
# Copy and resize old image into new image
imagecopyresampled($tmp_img1, $OriginalImage, 0, 0, 0, 0, ($new_width1+1), ($new_height1+1), $OriginalWidth, $OriginalHeight);
// NOTE: the -2 makes the holding image slightly smaller than the transferred image to eliminate black borders on the smaller image.
imagedestroy($OriginalImage);
$ThumbImg1 = $tmp_img1;
$tempName=explode(".",$imgfilename);
$newName1=$tempName[0]."_$imageSize.jpg";
$ThumbFileName1="$abpath/$newName1";
imagejpeg($ThumbImg1, $ThumbFileName1,75);
imagedestroy($ThumbImg1);
if($destroy_original=="yes") {
unlink("$abpath/".$imgfilename);// destroy the originally uploaded file.}
}
else{
$log.=" <br>Image NOT created - contact webmaster <br>";
} else {
$log .= $_FILES[$xxx]['name']." is not a supported file type. Its file type is ".$_FILES[$xxx]['type']."<br>";
}
}
}
return $log;
}/// end of function
$log=upload_resize_images("store_photo1",150,"experience_thumbs","no");
$log.=upload_resize_images("store_photo1",450,"experience_thumbs","yes");
$log.=upload_resize_images("store_photo2",150,"experience_thumbs","no");
$log.=upload_resize_images("store_photo2",450,"experience_thumbs","yes");
?>
<form name="frm" action="post.php" method="post" enctype="multipart/form-data">
<?
for($i=1;$i<=2;$i++)
{
echo"<input type=\"file\" name=\"store_photo$i\" size=60 id=\"uploadfile1\"><br>
<input style=\"font-size: 12px;\" type=\"text\" name=\"caption$i\" value=\"Enter Caption\" size=\"50\" onclick=\"this.value='';\" /><br /><br />";
}
?>
<input type="submit" name="button" id="button" value="Post Experience" />
|
Advertisement
| Hall of Fame |