Jump to content

Upload document option??


suess0r

Recommended Posts

Hi,

 

I'm trying to build an upload document option for my site. I'm having some issues with my form, but mostly with the updir.php which actually stores the file in a folder on the site. Here's what i got

 

<form action="updir.php" method="post" enctype="multipart/form-data">

<label for="file">

<div align="center">Filename:

  <label>

    <input type="file" name="file" id="file" >

    <input type="submit" name="submit" value="Submit" >

  <br >

</div>

</form>

 

and now updir.php

<?php

if ($_FILES["file"]["error"] > 0)

  {

  echo "Error: " . $_FILES["file"]["error"] . "<br />";

  }

else

  {

  echo "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"];

  echo "<br>";

  }

 

if (file_exists("/docs/" . $_FILES["file"]["name"]))

      {

      echo $_FILES["file"]["name"] . " already exists. ";

      }

    else

      {

      move_uploaded_file($_FILES["file"]["tmp_name"],

      "upload/" . $_FILES["file"]["name"]);

      echo "Stored in: " . "docs/" . $_FILES["file"]["name"];

      }

?>

 

I'm getting the following errors back...

Upload: BaumannProposal.doc

Type: application/msword

Size: 78 Kb

Stored in: /tmp/phpSw4XSl

 

Warning: move_uploaded_file(upload/BaumannProposal.doc): failed to open stream: No such file or directory in /home/content/s/u/e/suess0r/html/updir.php on line 22

 

Warning: move_uploaded_file(): Unable to move '/tmp/phpSw4XSl' to 'upload/BaumannProposal.doc' in /home/content/s/u/e/suess0r/html/updir.php on line 22

Stored in: docs/BaumannProposal.doc

 

Anyone have any ideas? Also, once I can get this I want to password protect the directory so someone can log in and get to the documents... Little helppp?

Link to comment
https://forums.phpfreaks.com/topic/50859-upload-document-option/
Share on other sites

f (file_exists("/docs/" . $_FILES["file"]["name"]))

      {

      echo $_FILES["file"]["name"] . " already exists. ";

      }

    else

      {

      move_uploaded_file($_FILES["file"]["tmp_name"],

      "upload/" . $_FILES["file"]["name"]);

      echo "Stored in: " . "docs/" . $_FILES["file"]["name"];

      }

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.