levidyllan Posted May 8, 2006 Share Posted May 8, 2006 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 Quote Link to comment Share on other sites More sharing options...
ober Posted May 8, 2006 Share Posted May 8, 2006 Did you chmod the upload/moved to folder to 777? Quote Link to comment Share on other sites More sharing options...
levidyllan Posted May 8, 2006 Author Share Posted May 8, 2006 [!--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. Quote Link to comment Share on other sites More sharing options...
Linc Posted May 9, 2006 Share Posted May 9, 2006 What version of PHP are you running? I know 5.1.3 had some file uploading bugs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.