Page 2 of 2

Posted: Wed Jun 02, 2004 6:39 am
by ddragas
Thank you. If I have furder questions I'll post them

Posted: Thu Jun 03, 2004 3:02 am
by ddragas
I get PARSE ERROR in LINE 41

error:
"Parse error: parse error, unexpected T_ELSE in c:\program files\apache group\apache\htdocs\cro1\resize\tmp4di3lyq3k0.php on line 41
"

where Am I misssing "{" and "}" ?


this is line 41

else // line 41





and complete code:

Code: Select all

<?php 
include_once("ImageResizeFactory.php"); 
if($_SERVER['REQUEST_METHOD'] === "POST") 
{ 
   ini_set("max_execution_time","3000"); 
    

    $maxSize = "2048576"; // 2MB upload size of the file. 
	$width1 = "800"; 
    $height1 = "800";     
	$width = "300"; 
    $height = "300"; 
	
    $allowedExtensions = array("jpg", "JPG", "JPEG", "png", "PNG"); 

    $errors = array(); 

$first = true; 

    foreach($_FILES as $data) 


{ 
if($first) 

  			processUpload($data,$maxSize,$width1,$height1,$allowedExtensions); // first file 

			$conn = mysql_connect("localhost","", "") or
			die ("Could not connect to localhost");

			mysql_select_db("slike") or
			die("Nije mogu&#263;e pristupiti bazi podataka");

			$query = "INSERT INTO apartmani (ID, slika1)
			VALUES ('$userID', '$Photo_Dir . $User_Dir . $yyyymmdd . $uploadedFileName')";
			mysql_query($query) or die (mysql_error());

			mysql_close($conn); 


else  // line 41
  			processUpload($data,$maxSize,$width,$height,$allowedExtensions); // all other files 
$first = false; 
}
    
    { 
        $ret = processUpload($data,$maxSize,$width,$height,$allowedExtensions); 
        if(!is_bool($ret)) 
            $errors[] = $ret; 
    } 
    
    if(!empty($errors)) 
        $error = implode("<br />\n",$errors); 
    else 
        exit("Upload slika uspješno izvršen...."); 
} 

function processUpload($data,$maxSize,$width,$height,$allowedExtensions) 
 {
   $uploadedFileName = $data['name']; // LINE 45
   $localtime = mktime();// the current datetime as a timestamp 
   $yyyymmdd = date("d_m_y__H_i_s__", $localtime); 
   $Photo_Dir = "uploadedfiles/"; 
   $userID = "2251"; 
    
   $User_Dir = $userID ."/"; 
    
         if (!is_dir($Photo_Dir.$User_Dir)) 
               { 
                    mkdir ($Photo_Dir.$User_Dir, 0777); 
                    chmod ($Photo_Dir.$User_Dir, 0777); 
               } 
    
    if($data['size'] > $maxSize) 
    { 
        $error = "Slika nesmije biti ve&#263;a od 2MB"; 
    } 
    if(file_exists($Photo_Dir . $uploadedFileName)) { 
        $error = "Slika sa imenom " . $uploadedFileName . " ve&#263; postoji<br>"; 
    } 
    $extension = pathinfo($data['name']); 
    $extension = $extension["extension"]; 
    $allowedExtensions = '#^'.implode("|",$allowedExtensions).'$#i'; 
    $boolValidExt = preg_match($allowedExtensions,$extension); 
    if($boolValidExt) { 
        if(empty($error) && is_uploaded_file($data['tmp_name'])) { 
            copy($data['tmp_name'], $Photo_Dir . $uploadedFileName); 
        } 
    } 
    else 
    { 
        $error = "Datoteka sa .$extension ekstenzijom nije dopuštena !!!"; 
    } 
    if(empty($error)) 
    { 
        $srcFile = $Photo_Dir . $uploadedFileName; 
        $destFile = $Photo_Dir . $User_Dir . $yyyymmdd . $uploadedFileName; 

        // Instantiate the correct object depending on type of image i.e jpg or png 
		$objResize = ImageResizeFactory::getInstanceOf($srcFile, $destFile, $width, $height); 
        // Call the method to resize the image 
        $objResize->getResizedImage(); 
        unlink($srcFile); 
        unset($objResize); 
//        header("Location:" . $destFile); 
//        exit; 
    } 

    if(!empty($error)) 
        return $error; 
    else 
        return true; 

} 
?> 


<HTML> 
<HEAD> 
<TITLE></TITLE> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250"></HEAD> 
<BODY> 
<FORM name="frmupload" method="POST" enctype="multipart/form-data"> 
  Slika 1 
  <input type="file" name="filename"> 
  <br> 
  Slika 2 
  <input type="file" name="filename1"> 
  <br> 
  Slika 3 
  <input type="file" name="filename2"> 
  <br> 
  Slika 4 
<input type="file" name="filename3"> 
  <br> 
  Slika 5 
<input type="file" name="filename4"> 
  <br> 
  Slika 6 
<input type="file" name="filename5"> 
  <br> 
  Slika 7 
<input type="file" name="filename6"> 
  <br> 
  <br> 
  <br> 
  <input type="submit" name="bupload" value="Resize"> 
  <input name="reset" type="reset" value="Clear"> 
  <font color="red"><b><?php if(!empty($error)) echo $error;?></b></font> 
  <TABLE align="center"> 
    <TR> 
          
      <TD>  </TD> 
    </TR> 
</TABLE> 
<INPUT type="hidden" name="hdnupload" value="false"> 
</FORM> 
</BODY> 
</HTML> 


<?php

?>

Posted: Thu Jun 03, 2004 5:53 am
by feyd
your missing braces {} around the if's code..

Posted: Fri Jun 04, 2004 1:50 am
by ddragas
Thank you for helping me. It's working perfetly.

One more question.

How can I make tumbail of first image?

Should it be something like


imagecopy(first picture)

and then to resize it and save path in database.

$width2= 'some value";
$height2='some value";

processUpload($data,$maxSize,$width2,$height2,$allowedExtensions);

Posted: Fri Jun 04, 2004 2:28 pm
by ddragas
ANYBODY???? PLEASE