Results 1 to 10 of 11
Hybrid View
-
9th Jun 2011, 11:44 AM #1OPMember
Please help me find a fix
Hello my friends,
Im here to request your help fixing 2 littleee things
I have an upload page in my website, where my users can send their photos directly to my website. But I need to fix this:
1- When someone uploads a big photo, the image brokes my layout...
I need to automatically resize the uploaded image with a limit of 800px width. It is possible in the code below? How?
2- When they send the photos, the date will be saved in my database, but I need also the time... It is possible in the code below? How?
PHP Code:<?
include("library/globals.php");
$dbc=mysql_connect($host,$username,$password) or die('Unable to connect to the database...');
mysql_select_db($dbname) or die('Unable to select the database...');
if(isset($_POST['submt']))
{
$name=$_POST['name'];
$country=$_POST['country'];
$email=$_POST['email'];
$picture=$_FILES['picture']['name'];
$comment=$_POST['comment'];
$arr=explode('.',$picture);
$img=date('ymdhis').".".$arr[1];
$dest="uploaded/".$img;
$dt=date('Y/m/d');
$cur_dt=date('Y-m-d');
$val1=move_uploaded_file($_FILES['picture']['tmp_name'],$dest);
if($val1)
{
$source_img=$dest;
$watermark = imagecreatefrompng('images/logo.png');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
$image = imagecreatefromjpeg($source_img);
$size = getimagesize($source_img);
$dest_x = $size[0] - $watermark_width - 2;
$dest_y = $size[1] - $watermark_height - 2;
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
imagejpeg($image,$source_img);
$qry="insert into thon_post (`name`,`picture`,`country_name`,`dt`,`email`,`comment`,`start_date`) values('$name','$img','$country','$dt','$email','$comment','$cur_dt')";
$rs=mysql_query($qry);
$val2=mysql_insert_id();
$dt=date('Y/m/d');
$str=$val2."%%".$dt."%%http://www.thongsaroundtheworld.com/conteudo/p.php?id=".$val2."%%0%%\n";
$fp=fopen('ccount/clicks.txt',"a");
fwrite($fp,$str);
fclose($fp);
if($val2>0)
{
?>
<script language="javascript" type="text/javascript">
alert('Congratulations! Your request is successfully looged in our server.\nWhen we will approve it, it will be displayed in our website.');
//window.location.href='upload.php';
window.close();
</script>
<?
}
}
}
?>Divvy Reviewed by Divvy on . Please help me found a fix Hello my friends, Im here to request your help fixing 2 littleee things :) I have an upload page in my website, where my users can send their photos directly to my website. But I need to fix this: 1- When someone uploads a big photo, the image brokes my layout... I need to automatically resize the uploaded image with a limit of 800px width. It is possible in the code below? How? 2- When they send the photos, the date will be saved in my database, but I need also the time... It is Rating: 5
-
9th Jun 2011, 02:06 PM #2Respected Member
Change the line:
PHP Code:$dt=date('Y/m/d');
PHP Code:$dt = date('Y/m/d H:i:s');
-
9th Jun 2011, 04:36 PM #3OPMember
Lock Down, thank you for your reply mate!
Btw, I have two lines with the same code... I need to replace the 1st line? 2nd? or both?
How about the image resize? Can you help me with that too?
-
9th Jun 2011, 05:42 PM #4Respected Member
You are welcome. I would say to keep them the same change them both.
-
9th Jun 2011, 05:55 PM #5Member
If the images are comming from a loop, you can add a class to the images and give it the following css atributes:
Code:.resize { width: 800px; height : auto; } .resize { width: auto; height : 800px; }
-
9th Jun 2011, 06:01 PM #6MemberWebsite's:
wautoposter.comAdd this in you css
Code:img { width: 100%; }
Code:http://unstoppablerobotninja.com/entry/fluid-images
-
9th Jun 2011, 09:33 PM #7Respected Member
Sorry I missed the part of making 800 the max width.
change this :
PHP Code:$dest_x = $size[0] - $watermark_width - 2;
$dest_y = $size[1] - $watermark_height - 2;
PHP Code:if ($srcsize[0]>800){ $percent = 800/$srcsize[0]; } else { $percent = 1; }
$dest_x = ($size[0]*$percent) - $watermark_width - 2;
$dest_y = ($size[1]*$percent) - $watermark_width - 2;
-
10th Jun 2011, 12:10 AM #8OPMember
Thank you for your replies mates
Lock Down, I changed the date codes, but I think that doesn't work... I made an test upload, and saw my database table:
http://screensnapr.com/e/sLTc8R.jpg
Do I need to create a new field for time? If yes, how can I integrate that with my admin panel:
http://screensnapr.com/e/ttnyly.jpg
About the image resize, doesnt work either, the only thing that happened, was the watermark that moved placeTake a look at the test upload image:
http://www.boobsaroundtheworld.com/u...0610015253.jpg
Anymore ideas?
-
10th Jun 2011, 01:40 AM #9Respected Member
What size and type did you make for the date? It will hold both if it is correct size and type.
ok for resize change this:
PHP Code:$source_img=$dest;
$watermark = imagecreatefrompng('images/logo.png');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
$image = imagecreatefromjpeg($source_img);
$size = getimagesize($source_img);
$dest_x = $size[0] - $watermark_width - 2;
$dest_y = $size[1] - $watermark_height - 2;
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
imagejpeg($image,$source_img);
PHP Code:$source_img=$dest;
// Get new sizes
list($width, $height) = getimagesize($dest);
if ($width>800) { $percent = 800/$width; } else {$percent = 1; }
$newwidth = $width * $percent;
$newheight = $height * $percent;
// Load
$source_img = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($dest);
// Resize
imagecopyresized($source_img, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Watermark
$watermark = imagecreatefrompng('logo.png');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
imagecopymerge($source_img, $watermark, $newwidth-$watermark_width-2, $newheight-$watermark_height-2, 0, 0, $watermark_width, $watermark_height, 75);
imagejpeg($source_img);
-
11th Jun 2011, 01:54 AM #10OPMember
Lock Down, thank you for your reply mate!
about the time issue, already fixed... I changed the database field from DATE to DATETIME
about the resize, tried your code and didnt work... got some errors in background.
but thats ok, I found a javascript to automaticly resize in my layout, and now looks fine.
Thank you again Lock Down, and all who leaved here their tips
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
404 not found - cgi
By xandor in forum Webmaster DiscussionReplies: 4Last Post: 10th Feb 2012, 09:13 PM -
Found out i could have a kid
By bmoeller in forum General DiscussionReplies: 5Last Post: 25th May 2011, 06:25 AM -
Hello Just Found KWWH
By Jeeny in forum IntroductionsReplies: 6Last Post: 3rd Mar 2011, 01:23 PM -
404 Not found
By SpiderZq in forum Server ManagementReplies: 8Last Post: 15th Sep 2009, 12:36 AM
themaCreator - create posts from...
Version 3.45 released. Open older version (or...