Jump to content

PHP - Move_Uploaded File Error


Heero

Recommended Posts

Hello all,

I am running this code on my [url=http://202.71.227.137/rehab/CMS/cmsadmin/move_uploaded_file.php]server[/url]:

[CODE]
<?php
include("phpincludes/userSessionCheck.php");

if (!isset($_REQUEST["seenform"])) {
?>
  <form enctype="multipart/form-data" action="move_uploaded_file.php" method="post">
  Upload file: <input name="userfile" type="file">
  <input type="submit" value="Upload">
  <input type="hidden" name="seenform">
  </form>
<?php
} else {
  $uploaded_dir = "/upload/";
  $filename = $_FILES["userfile"]["name"];
  $path = $uploaded_dir . $filename;

  print "Temporary name: " . $_FILES['userfile']['tmp_name'] . "<br>";
  print "Original name: $filename<br>";
  print "Destination: $path<br>";

  if (move_uploaded_file($_FILES["userfile"]["tmp_name"], $path)) {
      print "Uploaded file moved";
      // do something with the file here
  } else {
      print "Move failed";
  }
}

?>
[/CODE]

But I keep getting an move error. 

[QUOTE]
Temporary name: /tmp/phpx6PnbE
Original name: book_32.psd
Destination: /upload/book_32.psd
Move failed
[/QUOTE]

What can possible be creating this problem?

Link to comment
Share on other sites


be also carefull the correct form format is as follows.

notice the upper case letters and words .


<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="__URL__" method="POST">
    <!-- MAX_FILE_SIZE must precede the file input field -->
    <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
    <!-- Name of input element determines name in $_FILES array -->
    Send this file: <input name="userfile" type="file" />
    <input type="submit" value="Send File" />
</form>
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.