Darkmatter5 Posted January 5, 2009 Share Posted January 5, 2009 Here's my code <form method="post"> <table> <tr><td colspan="2"><b>Add new system</b></td></tr> <tr><td align="right">System name:</td><td><input type="text" name="name"></td></tr> <tr><td align="right">System Logo:</td><td><input type="file" name="file"></td></tr> <tr><td colspan="2"><input name='add_system' type='submit' class='button' tabindex='3' value='Add new system'/> <?php if(isset($_POST['add_system'])) { if($_POST['name']=="") { echo "<span class='dbstatusRED_text'>System name was left blank!</span>"; } else { include 'library/config.inc.php'; $conn=mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbname); $countquery=mysql_query("SELECT COUNT(name) as count FROM systems WHERE name='$_POST[name]'") or die(mysql_error()); $count=mysql_fetch_array($countquery); if ($count['count']>0) { echo "<span class='dbstatusRED_text'>'$_POST[name]' already exists in the database!</span>"; } else { if(isset($_POST['file']) && $_POST['file']!="") { if($_FILES['file']['error']>0) { echo "<br><span class='dbstatusRED_text'>Error: " .$_FILES['file']['error']. "</span><br>"; } else { echo "<br>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']. "<br>"; } } } //$insertquery=mysql_query("INSERT INTO systems (name) VALUES ('$_POST[name]')") or die(mysql_error()); echo "<span class='dbstatusGREEN_text'>'$_POST[name]' added to the database!</span>"; mysql_close($conn); } } ?> </td></tr> </table> </form> When I select a file the Upload: Type: Size: Stored in: Parts gets outputted to the page, but not $_Files data shows up. Whow come? Link to comment https://forums.phpfreaks.com/topic/139593-help-with-file-management/ Share on other sites More sharing options...
dennismonsewicz Posted January 5, 2009 Share Posted January 5, 2009 make sure you have the following in your <form> tag ENCTYPE = "multipart/form-data" Link to comment https://forums.phpfreaks.com/topic/139593-help-with-file-management/#findComment-730272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.