kafia Posted August 2, 2009 Share Posted August 2, 2009 I visted a tutorial on teh w3schools and try to load the image file on my server the html for code is as below.<html><body><form action="upload_file.php" method="post"enctype="multipart/form-data"><label for="file">Filename:</label><input type="file" name="file" id="file" /> <br /><input type="submit" name="submit" value="Submit" /></form></body></html> now i have the upload_file_php file code as below<?phpif ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; }else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; }if ((($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpeg")|| ($_FILES["file"]["type"] == "image/pjpeg"))&& ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } }else { echo "Invalid file"; }?> when i run it in my browser and tryt to upload a image file it show the following messege.Upload: concept-01_small.jpgType: image/pjpegSize: 3.240234375 KbStored in: /tmp/php9fJVURUpload: concept-01_small.jpgType: image/pjpegSize: 3.240234375 KbTemp file: /tmp/php9fJVURStored in: upload/concept-01_small.jpg now my problem is that i dont know where that file is on my server . first i create myself a folder named "upload" on my server and after loading the file i try to see that if that folder have that file in it but there was nothing . after i delete that folder and again run this script again same out but, please help me to understand it . helpfull replies are welcomed in advance. Link to comment Share on other sites More sharing options...
Ingolme Posted August 2, 2009 Share Posted August 2, 2009 The upload/ folder has to be in the same directory as the script.Your file should be there if you have run the script already Link to comment Share on other sites More sharing options...
kafia Posted August 3, 2009 Author Share Posted August 3, 2009 The upload/ folder has to be in the same directory as the script.Your file should be there if you have run the script alreadyFirst of all thank you to reply me but my problem is not solved , i explaned in my post that i try it both way by creating the upload/folder in teh same directory of my server where my script is but after uploading the image i opne that folder from my ftp client but its empty no file in it helpful reply is welcomed again Link to comment Share on other sites More sharing options...
Ingolme Posted August 3, 2009 Share Posted August 3, 2009 I'm afraid I can't help much more without more information.There may be permission problems with the folder.The following is debugging code, it doesn't handle exceptions but it's reduced to only the most basic lines necessary to upload a file. Create a new file and try this code in it to see if it works: <?phpif(!preg_match("/\.(php|exe)$/i",$_FILES['file']['name'])) { $x = move_uploaded_file($_FILES["file"]["tmp_name"],$_FILES["file"]["name"]); if($x) { echo "upload successful" } else { echo $_FILES['file']['error']; }} else { echo "Wrong file type";}?> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.