<?php
$mimi=$mzrow[idoferta];
if ($_POST[submit3]){
$form_data=$_FILES['form_data'];
$fileName = $_FILES['form_data']['name'];
$tmpName = $_FILES['form_data']['tmp_name'];
$fileSize = $_FILES['form_data']['size'];
$fileType = $_FILES['form_data']['type'];
if(!trim($fileName))
{
echo "<br><font color=red face=verdana size=2><b>No photo selected<BR><a href=detaliianunt.php?anuntnr=".$mimi.">Click here to try again!</a>";
die();
}
if (!(($fileType == "image/jpeg") || ($fileType == "image/pjpeg")))
{
echo "<br><font color=red face=verdana size=2><b>Only jpeg/jpg format accepted!<BR><a href=detaliianunt.php?anuntnr=".$mimi.">Click here to try again!</a></font>";
die();
}
// This is the temporary file created by PHP
$uploadedfile = $_FILES['form_data']['tmp_name'];
// Create an Image from it so we can do the resize
$src = imagecreatefromjpeg($uploadedfile);
// Capture the original size of the uploaded image
list($width,$height)=getimagesize($uploadedfile);
// For our purposes, I have resized the image to be
// 600 pixels wide, and maintain the original aspect
// ratio. This prevents the image from being "stretched"
// or "squashed". If you prefer some max width other than
// 600, simply change the $newwidth variable
$newwidth=400;
$newheight=($height/$width)*400;
$tmp=imagecreatetruecolor($newwidth,$newheight);
// this line actually does the image resizing, copying from the original
// image into the $tmp image
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
// now write the resized image to disk. I have assumed that you want the
// resized, uploaded image file to reside in the ./images subdirectory.
$filename = "../poze/".$mimi."_3.jpeg";
imagejpeg($tmp,$filename,98);
imagedestroy($src);
imagedestroy($tmp);
// NOTE: PHP will clean up the temp file it created when the request
// has completed.
$cucuid=$_POST['zid'];
$cxn = @ConnectToDb($dbServer, $dbUser9, $dbPass9, $dbName9);
$insert="INSERT INTO poza3 (id, poza, pass)VALUES ('$cucuid', '$data', '$_COOKIE[vanzinch_pass]')";
$rsult = mysql_query($insert) or die("EROARE INTRODUCERE POZA");
$upd="UPDATE oferte SET poza3='da' WHERE idoferta='$mimi' LIMIT 1";
$rsult = mysql_query($upd) or die("Query failed la Update");
$randy=rand(1,1000);
echo"<img border=1 src=../poze/".$mimi."_3.jpeg?randy=$randy;><br><a href=delete_free.php?action=delete&id=".$mzrow[idoferta]."&no=3><font size=1 color=red>delete [X]</font></a><br>";
}
else{
?>
<br>
<table><tr><td bgcolor=#ffffff>
<form method="post" action="detaliianunt.php?anuntnr=<?php echo $mimi;?>" enctype="multipart/form-data">
<input type="hidden" name="zid" value="<?php echo $mimi; ?>">
<p>
<input type="file" name="form_data" size="20">
<input type="submit" name="submit3" value="Upload Picture"></p>
</form></td></tr></table>
<?php
}?>