Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/9300-upload-issue/
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.

Link to comment
https://forums.phpfreaks.com/topic/9300-upload-issue/#findComment-34347
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.