uploading in php
Posted: Thu May 11, 2006 11:57 am
Hello, I want users to be able to upload images to my server. I tried
using the code from the PHP manual website but my servers PHP log
catches a syntax error where there is none. I have a folder called
images, and my apache/php is set to accept files. Here is the code
perhaps you guys have any tips or another tutorial.
thanks
this is my first file, i dont think it has anything wrong with it
index.html
Here is the second file uploader.php
Im running a Apache php mySql package for OSX called MAMP
thanks
-tony
using the code from the PHP manual website but my servers PHP log
catches a syntax error where there is none. I have a folder called
images, and my apache/php is set to accept files. Here is the code
perhaps you guys have any tips or another tutorial.
thanks
this is my first file, i dont think it has anything wrong with it
index.html
Code: Select all
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>Code: Select all
$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!";
}thanks
-tony