Jump to content


Photo

upload issue


  • Please log in to reply
3 replies to this topic

#1 levidyllan

levidyllan
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • Locationin the corner of this sphere

Posted 08 May 2006 - 10:22 AM

I am trying this simple upload form on my local server, at the moment before i produce it on the web. Its a simple upload script at the moment, the security checks etc will all be added later, just trying to get the whole upload / copy thing to work first.

But it seems not to be working keep getting the error mesage.

Using Mac, on local, as far as i can see the folders are all set to my username permission read and write, any ideas , please find code below???

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
<h3>UPLOAD IMAGE</h3>
Please select an Image to Upload:<br/>
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="600000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>

the php code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
<?php
// Where the file is going to be placed 
$target_path = "uploads/";

/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

// This is how we will get the temporary file...
$_FILES['uploadedfile']['tmp_name'];

$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}

?>

</body>
</html>

thanxs
Sorry, i am not here at the moment please leave a message after the Beep...!
BEEEEEP!

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 08 May 2006 - 02:08 PM

Did you chmod the upload/moved to folder to 777?

Info: PHP Manual


#3 levidyllan

levidyllan
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • Locationin the corner of this sphere

Posted 08 May 2006 - 05:32 PM

[!--quoteo(post=372268:date=May 8 2006, 03:08 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 8 2006, 03:08 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Did you chmod the upload/moved to folder to 777?
[/quote]

thanks for the reply. I am trying it locally, on a MAC and set all folders to read and write permissions.


Sorry, i am not here at the moment please leave a message after the Beep...!
BEEEEEP!

#4 Linc

Linc
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 09 May 2006 - 04:01 PM

What version of PHP are you running? I know 5.1.3 had some file uploading bugs.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users