I m sorry this is the first time that I have posted nything on this site..
I am sending my entire code so that u can have an idea as to what I m doing.You can just go to the bottom of the page to the word wrap function
Here is the code..
<?php
$title=$POST["title"];
$description = $POST["description"];
$subject = $POST["subject"];
$month=$POST["month"];
$day=$POST["day"];
$year=$POST["year"];
$eventdate= $month."-".$day."-".$year;
$submit=$_POST["submit"];
?>
<head>
<LINK href="iframe.css" rel="stylesheet" type="text/css">
</head>
<body background="images/home/frame_body.jpg" bgproperties="fixed"><?
$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$upload_dir = "lessons/fullimages/";
$upload_dir1 = "lessons/flashimages/";
$upload_url = $url_dir."/lessons/fullimages/";
$message ="";
if (!is_dir("lessons/fullimages")) {
die ("lessons/fullimages directory doesn't exist");
}
if ($_FILES['userfile']) {
$message = do_upload($title, $subject, $eventdate,$description, $upload_dir, $upload_url);
}
else {
$message = "Select a file to upload...";
}
echo "<h3>$message</h3>";
function do_upload($title, $subject, $eventdate,$description, $upload_dir, $upload_url)
{
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
$result = $_FILES['userfile']['error'];
$file_url = $upload_url.$file_name;
$file_path = $upload_dir.$file_name;
$file_path1 = $upload_dir1.$file_name;
//File Name Check
if ( $file_name =="") {
$message = "<b><font color=#FF0000>Select a valid file...<p></font><b>";
return $message;
}
//File Size Check
else if ( $file_size > 500000) {
$message = "The file size is over 500K.";
return $message;
}
//File Type Check
else if ( $file_type == "text/plain" ) {
$message = "Sorry, You cannot upload any script file" ;
return $message;
}
$result = move_uploaded_file($temp_name, $file_path);
$thisresult = move_uploaded_file($temp_name, $file_path1);
$message = ($result)?"Your file is uploaded successfully" : "Somthing is wrong with uploading your file.";
$max = "SELECT max(picture_id) as picture_id from pictureupload";
$mymax = mysql_query($max) or die (mysql_error());
while($maxresult = mysql_fetch_array($mymax,MYSQL_BOTH))
{
$thisid = $maxresult['picture_id'];
}
$myquery = "SELECT * FROM pictureupload WHERE picture_id ='$thisid'";
$mypath = @mysql_query($myquery) or die(mysql_error());
while($result = mysql_fetch_array($mypath,MYSQL_BOTH))
{
$path = $result["picture_path"];
}
if(strpos($path,"baseUp.jpg"))
{
$srcfile = "lessons/images/baseDown.jpg";
}
else if(strpos($path, "baseDown.jpg"))
{
$srcfile = "lessons/images/baseUp.jpg";
}
else
{
$srcfile = "lessons/images/baseUp.jpg";
}
$img1 = $upload_dir.$file_name;
$img = getimagesize($img1);
$w = $img[0];
$h = $img[1];
if($w > $h && $w > 89)
{
$percent_div = 89/$w;
$width = 89;
$height = $percent_div * $h;
$height = floor($height);
}
if($h > $w && $h > 118){
$percent_div = 118/$h;
$height = 118;
$width = $percent_div * $w;
$width = floor($width);
}
$img2 = imagecreatefromjpeg($img1);
$thumb = imagecreatetruecolor($width,$height);
imagecopyresized($thumb, $img2 , 0, 0, 0, 0, $width, $height, $w, $h);
imagejpeg($thumb, "lessons/fullimages/$file_name", 100);
$srcfile1 = $srcfile;
$basename = basename($srcfile1);
$rest = substr("$file_name", 0, -4);
$destfile= "lessons/thumbimages/".$rest.$basename;
if (!copy($srcfile1, $destfile))
{
echo "failed to copy $file...\n";
}
$thissource = "lessons/fullimages/$file_name";
$thissize = getimagesize($thissource);
$wid = $thissize[0];
$hei = $thissize[1];
if($wid > $hei && $wid > 89)
{
$percent_div = 89/$wid;
$width = 89;
$height = $percent_div * $hei;
$height = floor($height);
}
if($hei > $wid && $hei > 44)
{
$percent_div = 44/$hei;
$height = 44;
$width = $percent_div * $wid;
$width = floor($width);
}
$thissrcImage = imagecreatefromjpeg("lessons/fullimages/$file_name");
$thumb1 = imagecreatetruecolor($width,$height);
imagecopyresized($thumb1, $thissrcImage , 0, 0, 0, 0, $width, $height, $wid, $hei);
imagejpeg($thumb1, "lessons/flashimages/$file_name", 100);
$desImage = imagecreatefromjpeg($destfile);
$srcImage = imagecreatefromjpeg("lessons/flashimages/$file_name");
if(strpos($destfile,"baseUp.jpg"))
{
imagecopymerge($desImage, $srcImage, 0, 0, 0, 0, 89, 44, 100);
}
else if(strpos($destfile,"baseDown.jpg"))
{
imagecopymerge($desImage, $srcImage, 0, 74, 0, 0, 89, 44, 100);
}
$handle=$destfile;
imagejpeg($desImage, $handle, 100);
$srcmerge = imagecreatefromjpeg("lessons/fullimages/$file_name");
$desmerge = imagecreatefromjpeg("lessons/images/baseimage.jpg");
imagecopymerge($desmerge, $srcmerge, 2, 12, 0, 0, 89, 67, 100);
imagejpeg($desmerge,"lessons/thumbflash/$file_name",100);
$im = imagecreatefromjpeg("lessons/thumbflash/$file_name");
$hello = "Date:";
$descr = "Subject:";
$textcolor = imagecolorallocate($im, 0, 0, 255);
imagestring ($im, 2, 43, 0 , $hello.$eventdate, $textcolor );
$newtext = wordwrap($description, 15, "\n");
imagestring ($im, 2, 1, 78 , $descr.$newtext, $textcolor );
imagejpeg($im,"lessons/thumbflash/$file_name",100);
//imagejpeg($desmerge,"lessons/thumbflash/$file_name",100);
if($message == "Your file is uploaded successfully")
{
$sql="insert into pictureupload(picture_title,picture_subject,picture_date,picture_description,picture_path)
values ('$title','$subject','$eventdate','$description','$destfile')";
mysql_query($sql);
$row = mysql_insert_id();
echo $row;?><br><?
$thisresult = "select * from pictureupload where picture_id ='$row'";
$rowresult = mysql_query($thisresult) or die (mysql_error());
while($thisrowresult = @mysql_fetch_array($rowresult,MYSQL_BOTH))
{
$thispicturedate = $thisrowresult["picture_date"];
$thispicturedesc = $thisrowresult["picture_description"];
echo $thispicturedate;?><br><?
echo $thispicturedesc;
return $message;
}
}
}
?>