Jump to content

can u tell me what the wrong in my code please?


mekha

Recommended Posts

//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 itelse{		 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.";		 }}

can u tell me what the problem ?

Link to comment
Share on other sites

why do you think your code is wrong? are you facing any problem or is it showing any error?

Link to comment
Share on other sites

Then I'd say your code is doing exactly what you told it to do, but not what you intended. Start echoing the variables in each condition. I'll bet you'll find the culprit.

Link to comment
Share on other sites

you have to do it like

  <script type='text/javascript'>alert("okk");</script>

if you have not error reporting enabled make it enabled. it will help you in future to debug"display_error" set to ON"error_reporting" set to E_ALL you can use ini_set() at top most part of your script. http://php.net/ini_Setor in php.ini

Link to comment
Share on other sites

Good one birbal. I thought he was talking about his echos seeing how this is the php forum. His ref to an alert should've caused me to look for something else. Good catch. Wasn't looking for JS so I didn't find any!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...