11Tami Posted July 7, 2007 Share Posted July 7, 2007 Hello I'm trying to upload a file to the server when a submit button is pushed. For instance, <?php ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" /><HTML> <TITLE>Uploading a file</TITLE> </HEAD> <BODY> <FORM ENCTYPE="multipart/form-data" NAME=MyForm ACTION=submit.php METHOD="POST"> <INPUT TYPE="hidden" NAME="command" VALUE="1"> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="100000"> <INPUT NAME="MyFile" TYPE="File"> <INPUT NAME="submit" VALUE="Upload" TYPE="submit"> </FORM> <?php $link = mysql_connect('database address', 'databasename', 'password'); if (!$link) { die('Not connected : ' . mysql_error()); } $db_selected = mysql_select_db('databasename', $link); if (!$db_selected) { die ('Can\'t use database : ' . mysql_error()); } $query = "SELECT softwarename FROM addsoftware WHERE `id` = '46'"; $result = mysql_query($query) or die(mysql_error()." ".$query); while ($row = mysql_fetch_array($result)) { echo <span>$row[softwarename]</span>"; } ?> <BR><BR> </CENTER> </BODY> </HTML> <?php $DestinationDir = "/uploadedfiles/"; $DestinationFile = $DestinationDir . $_FILES['MyFile']['name']; If (move_uploaded_file($_FILES['MyFile']['tmp_name'], $DestinationFile)) { Echo "File uploaded successfully."; }Else{ Echo $_FILES['MyFile']['error']; } ?> But I don't know how to upload the whole file instead of only whats in the submit form. The whole above example I found online says its supposed to upload a whole file yet this: $_FILES['MyFile']['name']; --is only asking for whats in the input of form of the page, not the whole page. Need help. Please let me know how to do this, thank you very much. Quote Link to comment Share on other sites More sharing options...
11Tami Posted July 7, 2007 Author Share Posted July 7, 2007 Same problem at w3 schools http://www.w3schools.com/php/php_file_upload.asp They show the file being the form data from what I can see. I need to upload the whole file itself and don't know how. 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.