Jump to content


Photo

PHP - Move_Uploaded File Error


  • Please log in to reply
6 replies to this topic

#1 Heero

Heero
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 02 August 2006 - 08:17 AM

Hello all,

I am running this code on my server:

<?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";
   }
}

?>

But I keep getting an move error. 

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


What can possible be creating this problem?


I'm learning PHP and mySQL. Please forgive my ignorance :(

#2 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 02 August 2006 - 08:25 AM

do u have the folder that u want to move it too set to 777
if not u need to CHMOD that folder to 777

#3 Heero

Heero
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 02 August 2006 - 08:56 AM

COol that fixed the problem.  But isn't it dangerous to set it to complete modification for the folder (ie. 777)?
I'm learning PHP and mySQL. Please forgive my ignorance :(

#4 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 02 August 2006 - 08:58 AM

um somtimes but not if your just setting it to one folder that doesnt have anything in it

#5 Heero

Heero
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 03 August 2006 - 01:04 AM

Oh okay...just curious...why would I even set a folder to full permissions if I won't anything in it?
I'm learning PHP and mySQL. Please forgive my ignorance :(

#6 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 03 August 2006 - 05:01 AM

thats why uploads should always go in thier own folder(or series of folders) and NEVER in ur main directory!
"Syntax error" .. WHERE THE **** IS IT?!

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 03 August 2006 - 05:06 AM


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>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users