spikypunker Posted January 11, 2008 Share Posted January 11, 2008 Right Feel a bit stupid about my last post cause i was being dumb and then the thread got too big, so i'm reposting it much simpler. ok I'm trying to allow a user to select a news item then a file and then get php to upload the file (will be a GIF) and name the file on the server in the uploads folder as the ID of the news item they chose. addimage.php <body> <form method="post" action="selectimage.php"> <? mysql_connect("db1", "stanga_1", "***"); @mysql_select_db("stanga_1") or die ("unable to connect"); $query = "SELECT * FROM news"; $result = mysql_query($query); $num = mysql_num_rows($result); mysql_close(); $i = 0; while ($i < $num) { $newsno = mysql_result($result,$i,"newsno"); $date = mysql_result($result,$i,"date"); $head = mysql_result($result,$i,"head"); $body = mysql_result($result,$i,"body"); ?> <input name="item" type="radio" id="item" value="<? echo $newsno; ?>"> <? echo " <span class='style2'>$head</span><br>"; $i++; } ?> <br /><Br /><br /> <span class="style1">Now Select the Image you wish to upload</span>...<br /><br /> <input name="uploadFile" type="file" /><br /><br /> <input type="submit" value="Add Image"/> </form> </body> selectimage.php <body> <span class="style1"> <? $id = $_POST['item']; $id = $id . ".gif"; $target_path = "uploads/"; $target_path = $target_path . basename( $id); echo $target_path; if(move_uploaded_file($_FILES['uploadedFile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> </body> So bascially this is passing the variable and creating the right file string but it's not uploading anything!!! It comes up with the message i've written in the script: "There was an error uploading the file, please try again!" This is driving me crazy! peace Link to comment Share on other sites More sharing options...
toplay Posted January 11, 2008 Share Posted January 11, 2008 Do not double post...continue with your first thread.... http://www.phpfreaks.com/forums/index.php/topic,176649.0.html topic locked. Link to comment Share on other sites More sharing options...
Recommended Posts