mekha Posted September 8, 2012 Share Posted September 8, 2012 //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 More sharing options...
birbal Posted September 8, 2012 Share Posted September 8, 2012 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 More sharing options...
Ingolme Posted September 8, 2012 Share Posted September 8, 2012 The only thing I notice is that $uploaded_size and $uploaded_type are not defined anywhere. Link to comment Share on other sites More sharing options...
mekha Posted September 8, 2012 Author Share Posted September 8, 2012 i do not get any errors...but the alert isnt work!... i tryed do define thim...and no alert :s Link to comment Share on other sites More sharing options...
niche Posted September 9, 2012 Share Posted September 9, 2012 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 More sharing options...
birbal Posted September 9, 2012 Share Posted September 9, 2012 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 More sharing options...
niche Posted September 9, 2012 Share Posted September 9, 2012 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.