Jump to content

Uploading to the server


11Tami

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.