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
https://forums.phpfreaks.com/topic/16300-php-move_uploaded-file-error/
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>

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.