Jump to content

Web site upload form wont write?


lonewolf007

Recommended Posts

Hello I have a web client and the upload form I have won't write the file to the folder. 

 

Here is the code I have.

 

<?php

/*************************************************

* Micro Upload

*

* Version: 0.1

* Date: 2006-10-27

*

* Usage:

* Set the uploadLocation variable to the directory

* where you want to store the uploaded files.

* Use the version which is relevenat to your server OS.

*

****************************************************/

 

//Windows way

$uploadLocation = "/Uploaded";

//Unix, Linux way

//$uploadLocation = "\tmp";

 

?>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"DTD/xhtml1-transitional.dtd">

<html>

<head>

<title>Upload Files - Dixon Design Services</title>

    <link href="style.css" rel="stylesheet" type="text/css" />

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"

/></head>

<body bgcolor="#0000FF" text="#FFFFFF" link="#FFFFFF">

<table width="900" border="0" align="center">

  <tr>

    <th scope="row"><p align="center">Welcome to </p>

    <p align="center">Dixon Design Services, LLC<br>

  (231) 929 - 7005</p>

    <p align="center">Experienced - Reliable - Responsive </p></th>

    <th scope="row"><div align="center"><img src="/Logouse.JPG"

width="166" height="139" alt="Dixon Design Services"

longdesc="http://www.dixondesignservices.com" /></div></th>

  </tr>

</table>

<p align="center"><SCRIPT src="../displayFlash.js"></SCRIPT></p>

    <div id="main">

      <div id="caption"><strong>UPLOAD FILE</strong></div>

      <div id="icon"></div>

      <form action="<?php echo $_SERVER['../PHP_SELF']; ?>" method="post"

name="fileForm" id="fileForm" enctype="multipart/form-data">

        <div align="center"><strong>File to upload:</strong>

        </div>

        <center>

        <table>

          <tr><td><input name="upfile" type="file" size="36"></td></tr>

          <tr><td align="center"><br/><input class="text" type="submit"

name="submitBtn" value="Upload"></td></tr>

        </table></center>

      </form>

<?php

    if (isset($_POST['submitBtn'])){

 

?>

      <div id="caption">RESULT</div>

      <div id="icon2"></div>

      <div id="result">

        <table width="100%">

<?php

 

  $target_path = $uploadLocation . basename( $_FILES['upfile']['name']);

 

  if(move_uploaded_file($_FILES['upfile']['tmp'], $target_path))

  {

      echo "The file: ".  basename( $_FILES['upfile']['name']).

      " has been uploaded!";

  }

  else

  {

    switch($_FILES['upfile']['error'])

    {

      case 0:

        echo "There is no error, the file uploaded with success. ";

      break;

      //

      case 1:

        echo "The uploaded file exceeds the upload_max_filesize directive

in php.ini. ";

      break;

      //

      case 2:

        echo "The uploaded file exceeds the MAX_FILE_SIZE directive that

was specified in the HTML form. ";

      break;

      //

      case 3:

        echo "The uploaded file was only partially uploaded. ";

      break;

      //

      case 4:

        echo "No file was uploaded. ";

      break;

      //

      case 6:

        echo "Missing a temporary folder. Introduced in PHP 4.3.10 and PHP

5.0.3. ";

      break;

      //

      case 7:

        echo "Failed to write file to disk. Introduced in PHP 5.1.0. ";

      break;

      //

      case 8:

        echo "File upload stopped by extension. Introduced in PHP 5.2.0.

";

      break;

      //

      default:

        echo "Unknown error";

    }

  }

 

?>

        </table>

      </div>

<?php

    }

?>

    <div>

</body>

 

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.