can you tell me my problem in this code pleasE?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mekha
Forum Contributor
Posts: 112
Joined: Sat Mar 31, 2012 6:50 am

can you tell me my problem in this code pleasE?

Post 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."; 
	 } 
 }
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

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

Post by social_experiment »

What is / isn't the code doing?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
mekha
Forum Contributor
Posts: 112
Joined: Sat Mar 31, 2012 6:50 am

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

Post by mekha »

doesnt alert "hi"
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

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

Post 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'];
         } 
?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Live24x7
Forum Contributor
Posts: 194
Joined: Sat Nov 19, 2011 9:32 am

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

Post 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 ??
Post Reply