Jump to content

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

      }

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.