dark22horse Posted April 24, 2007 Share Posted April 24, 2007 Hi I have had this working a some stage, but I am unsure what I have changed. This is my form <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Price<input type="text" name="price" length="20" /><br/> description<textarea name="description" rows="5" cols="35"></textarea><br/> Choose a file to upload: <input name="photo" type="file" /><input type="submit" value="Upload File" /><br /> This is my uploader.php <? require_once("mysql_config.php"); $target_path = $target_path . basename( $_FILES['photo']['name']); $_FILES['photo']['tmp_name']; $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['photo']['name']); if(move_uploaded_file($_FILES['photo']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded"; $sql_string = "INSERT INTO car(price, description, photo) VALUES ('".$_POST['price']."', '".$_POST['description']."', '".$_FILES['photo']['name']."')"; echo "<br/>SQL STRING WE WANT TO RUN: ".$sql_string; echo "db connection: ".$dbconn; echo "table connection: ".$table; $ok = mysql_query($sql_string); echo "OK: ".$ok; if($ok){ echo "<h2>all is good, upload another</h2>"; } else { echo "<h2>check the string".$sql_string."</h2>"; } } else{ echo "There was an error uploading the file, please try again!"; } ?> It brings up this error message "There was an error uploading the file, please try again!" Cheers Quote Link to comment Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 comment out the else that prints it and see if it returns an error Quote Link to comment Share on other sites More sharing options...
dark22horse Posted April 24, 2007 Author Share Posted April 24, 2007 not quite sure what you want me to do, bit more detail will help, im new to this! Quote Link to comment Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 } else{ echo "There was an error uploading the file, please try again!"; } change to: }// else{ // echo "There was an error uploading the file, please try again!"; //} and when you open the page in a browser it should return an error Quote Link to comment Share on other sites More sharing options...
dark22horse Posted April 24, 2007 Author Share Posted April 24, 2007 K didnt get an error message as such, but this came up [photo] => Array ( [name] => [type] => [tmp_name] => [error] => 4 => 0 ) Not sure what this means. Quote Link to comment Share on other sites More sharing options...
dark22horse Posted April 25, 2007 Author Share Posted April 25, 2007 bump Quote Link to comment Share on other sites More sharing options...
dark22horse Posted April 26, 2007 Author Share Posted April 26, 2007 can ne1 help? Quote Link to comment Share on other sites More sharing options...
aragon1337 Posted April 26, 2007 Share Posted April 26, 2007 The problem is most probably with the $target_path, thats why move_uploaded_file is returning false. Make sure you have the uploads directory in the same directory as the uploader.php Quote Link to comment Share on other sites More sharing options...
dark22horse Posted April 26, 2007 Author Share Posted April 26, 2007 Thats seems fine, it is in the folder with it. Maybe it is the Form?? <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Price<input type="text" name="price" length="20" /><br/> description<textarea name="description" rows="5" cols="35"></textarea><br/> Choose a file to upload: <input name="photo" type="file" /><input type="submit" value="Upload File" /><br /> Is that k? Quote Link to comment Share on other sites More sharing options...
Barand Posted April 26, 2007 Share Posted April 26, 2007 The output looks like that from print_r ($_FILES) and is showing the upload error Value: 4; No file was uploaded Quote Link to comment Share on other sites More sharing options...
dark22horse Posted April 26, 2007 Author Share Posted April 26, 2007 Sorry mate, unsure what you mean, i know im simple its not my fault Quote Link to comment Share on other sites More sharing options...
Barand Posted April 26, 2007 Share Posted April 26, 2007 I was referring to [pre] [photo] => Array ( [name] => [type] => [tmp_name] => [error] => 4 => 0 ) [/pre] Quote Link to comment Share on other sites More sharing options...
dark22horse Posted April 26, 2007 Author Share Posted April 26, 2007 I thought you were, guess what!! I am a newbie php person . Its sorted now. I had deleted the </form> at the end. HAHA this took me 3 days to work out! I suck, but cheers for all the help! you guys have helped me a lot, if only i could repay the favour. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.