Page 1 of 1

can you tell me my problem in this code pleasE?

Posted: Sat Sep 08, 2012 11:27 am
by mekha
hi huys,can you tell me my problem in this code pleasE?

Code: Select all

//file upload
		$target = "../uploads/sitefolders/"; 
		$target2 = time();
		$target3 = basename( $_FILES['uploaded']['name']);
		$rel1 = substr($target3, -3);
		$target = $target . $target2 . "." .$rel1 ;  
		 $ok=1; 
 
 //This is our size condition 
	 if ($uploaded_size > 350000) 
	 { 
		 echo "Your file is too large.<br>"; 
		 $ok=0; 
	 } 
 
 //This is our limit file type condition 
	 elseif ($uploaded_type =="text/php") 
	 { 
		 echo "No PHP files<br>"; 
		 $ok=0; 
	 } 
 
 //Here we check that $ok was not set to 0 by an error 
	 elseif ($ok==0) 
	 { 
		echo "Sorry your file was not uploaded"; 
	 } 
 
 //If everything is ok we try to upload it 
 else 
 { 
	 if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
	 { 
	 ?>
	 <script>alert("okk");</script>
	 <?php
	//	echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; 
		//header("location:index.php");
	 } 
	 else 
	 { 
		echo "Sorry, there was a problem uploading your file."; 
	 } 
 }

Re: can you tell me my problem in this code pleasE?

Posted: Sat Sep 08, 2012 11:31 am
by social_experiment
What is / isn't the code doing?

Re: can you tell me my problem in this code pleasE?

Posted: Sat Sep 08, 2012 11:32 am
by mekha
doesnt alert "hi"

Re: can you tell me my problem in this code pleasE?

Posted: Sat Sep 08, 2012 11:51 am
by social_experiment
Echo the value from $_FILES['uploaded']['error'] to see what error occured; have a look at the url below for the particular error code;
http://www.php.net/manual/en/features.f ... errors.php

Code: Select all

<?php
 else 
         { 
                //echo "Sorry, there was a problem uploading your file."; 
                echo $_FILES['uploaded']['error'];
         } 
?>

Re: can you tell me my problem in this code pleasE?

Posted: Sun Sep 09, 2012 10:26 pm
by Live24x7
and how does php know the literal meaning of variables $uploaded_size and $uploaded_type are supposed to mean what u intended them to mean ??