Jump to content

Archived

This topic is now archived and is closed to further replies.

levidyllan

upload issue

Recommended Posts

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???

[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>
<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>
[/code]

the php code:

[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>
[/code]

thanxs

Share this post


Link to post
Share on other sites
Did you chmod the upload/moved to folder to 777?

Share this post


Link to post
Share on other sites
[!--quoteo(post=372268:date=May 8 2006, 03:08 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 8 2006, 03:08 PM) [snapback]372268[/snapback][/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.

Share this post


Link to post
Share on other sites
What version of PHP are you running? I know 5.1.3 had some file uploading bugs.

Share this post


Link to post
Share on other sites

×

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.