Why is my file not being loaded?
ajax, forms, html, php, upload
Solution
change this
if(move_uploaded_file($file["name"]["tmp_name"],"./" . $file["name"])){
to
if(move_uploaded_file($file["tmp_name"],"./" . $file["name"])){
because you have assigned
$file = $_FILES["newPic"];
Problem
I am simply trying to upload a file and nothing is working. ``` <!DOCTYPE html> <html><body> <form id="exp" enctype = "multipart/form-data" action="../cgi-bin/uploadPic.php"> <input type="file" id="profilePic2" name="newPic"></input> <br /><br /><br /> <input type="submit" value="Upload Pic" style="color:black;"></input> </form> </body></html> ``` My php file is being executed. Please mind the sloppy code, I am trying to debug via echo. ``` <html> <body> <?php $loadFile = true; // error code $allowedExts = array("jpg","jpeg","gif","png"); $extension = end(explode(".", $_FILES["newPic"]["name"])); $file = $_FILES["newPic"]; $picIncluded = false; if(( ($_FILES["newPic"]["type"] == "image/gif") || ($_FILES["newPic"]["type"] == "image/jpeg") || ($_FILES["newPic"]["type"] == "image/png") || ($_FILES["newPic"]["type"] == "image/pjpeg")) && ($_FILES["newPic"]["size"] < 5000000) && in_array($extension, $allowedExts)){ if($_FILES["newPic"]["error"] > 0){ echo "pnl"; // error code returned to client } else if(file_exists("../profile-pics/" . $file["name"])){ echo "pld"; // picture loaded duplicate } else { $picIncluded = true; echo "finally"; if(move_uploaded_file($file["name"]["tmp_name"],"./" . $file["name"])){ echo "Success again!"; } $path = "../profile-pics/" . $file["name"]; } } if(is_uploaded_file($_FILES["newPic"]["name"]["tmp_name"])){ echo "Good news!"; } ?> </body> </html> ``` Anyway, the function move_uploaded_file() is returning false since it can't find the temp file. is_uploaded_file() is also return false. My extensions and everything is correct but still to no avail, there is no file being uploaded. How can I debug this?