emediastudios Posted February 5, 2008 Share Posted February 5, 2008 Hi everyone, i am having this problem wher my script keeps telling me i have attempted to upload a invalid file. and it isnt. Here is my code <?php require_once('../../Connections/worldgym.php'); error_reporting(E_ALL); //This gets all the other information from the form $photo=($_FILES['photo']['name']); $title=$_POST['title']; if ((($_FILES["photo"]["type"] == "image/gif") || ($_FILES["photo"]["type"] == "image/jpeg") || ($_FILES["photo"]["type"] == "image/jpg") || ($_FILES["photo"]["type"] == "image/pjpeg")) && ($_FILES["photo"]["size"] < 20000000)) { if ($_FILES["photo"]["error"] > 0) { echo "Return Code: " . $_FILES["photo"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["photo"]["name"] . "<br />"; echo "Type: " . $_FILES["photo"]["type"] . "<br />"; echo "Size: " . ($_FILES["photo"]["size"] / 10240) . " Kb<br />"; echo "Temp file: " . $_FILES["photo"]["tmp_name"] . "<br />"; if (file_exists("../gallery/" . $_FILES["file"]["name"])) { echo $_FILES["photo"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["photo"]["tmp_name"], "../gallery/" . $_FILES["photo"]["name"]); echo "Stored in: " . "../gallery/" . $_FILES["photo"]["name"]; } } } else { echo "Invalid file"; } ?> My form is like this <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Upload</title> <style type="text/css"> <!-- .style1 { color: #FFFFFF; font-weight: bold; } --> </style> </head> <body> <form id="form1" name="form1" method="post" action="process.php"> <table width="800" border="0" align="center"> <tr> <td colspan="2" bgcolor="#666666"><div align="center" class="style1">Image Upload Form</div></td> </tr> <tr> <td>Select Image</td> <td><label> <input type="file" name="photo" id="photo" /> </label></td> </tr> <tr> <td>Image Description</td> <td><label> <textarea name="title" cols="45" rows="10" id="title"></textarea> </label></td> </tr> <tr> <td> </td> <td><label> <input type="submit" name="button" id="button" value="Upload" /> </label></td> </tr> <tr> <td colspan="2" bgcolor="#666666"> </td> </tr> </table> </form> </body> </html> What could be possibly wrong. Link to comment https://forums.phpfreaks.com/topic/89541-solved-upload-image/ Share on other sites More sharing options...
harristweed Posted February 5, 2008 Share Posted February 5, 2008 I think is the form type that needs an addtion, try: <form id="form1" enctype="multipart/form-data" name="form1" method="post" action="process.php"> Link to comment https://forums.phpfreaks.com/topic/89541-solved-upload-image/#findComment-458655 Share on other sites More sharing options...
emediastudios Posted February 6, 2008 Author Share Posted February 6, 2008 Thanks champ, that was the problem. Link to comment https://forums.phpfreaks.com/topic/89541-solved-upload-image/#findComment-459538 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.