+ Reply to Thread
Results 1 to 7 of 7
-
Recommend Me a Simple PHP Image Upload Script
Hi All
Can anyone recommend me a simple PHP image upload script? It just needs to be able to upload one image to a particular folder on my server, I don't need anything particularly fancy, just looking for a best practice script.
Thanks
-
Registered User
- Join Date
- Jan 2008
- Location
- Pangaea
- Posts
- 644
- Thanks
- 22
- Thanked 35 Times in 29 Posts
Re: Recommend Me a Simple PHP Image Upload Script
something like this should work
and then in image-upload.phpHTML Code:<form enctype="multipart/form-data" action="image-upload.php" method="POST"> <fieldset> <input name="theimage" type="file" /> <input type="submit" value="Upload" /> </fieldset> </form>
PHP Code:$target_path = "/home/ACCOUNTNAME/public_html/images/";
$target_path = $target_path . basename( $_FILES['theimage']['name']);
if(move_uploaded_file($_FILES['theimage']['tmp_name'], $target_path)) {
echo "<p>The image ". basename( $_FILES['theimage']['name']). " has been uploaded</p>";
} else{
echo "<p>There was an error uploading the image, please try again!</p>";
}
-
The Following User Says Thank You to Andrew Starr For This Useful Post:
accelerator (02-06-09)
-
Re: Recommend Me a Simple PHP Image Upload Script
Thanks for that.
Rgds
-
Re: Recommend Me a Simple PHP Image Upload Script
As far as I can see there's nothing in that script to stop people uploading executable scripts - and as you're moving the file to a place that is publicly accessible I would by very careful using this without some form of extra validation in place (to check the file really is a harmless image).
More here: make upload file (move_uploaded_file) secure for public usage - CodingForums.com
-
Registered User
- Join Date
- Jan 2008
- Location
- Pangaea
- Posts
- 644
- Thanks
- 22
- Thanked 35 Times in 29 Posts
Re: Recommend Me a Simple PHP Image Upload Script
Of course, but accelerator was only asking for something quick & simple. I just assumed that he wanted to use it as a one-off
-
Re: Recommend Me a Simple PHP Image Upload Script
Yeh indeed, the warning was mostly for future people who may not know better yet. I can imagine someone simply copy pasting, it working and then them not thinking any more about it. Mostly from experience
-
Re: Recommend Me a Simple PHP Image Upload Script
I'm using it in the admin section of my site, behind htaccess password protection, so it should be ok. Thanks for your concern though.

Rgds
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Multi site upload script For Sale
By KPR in forum Domains & Websites For SaleReplies: 0Last Post: 08-02-09, 10:52 PM -
simple countdown script needed
By affiliatemarketingltd in forum ProgrammingReplies: 7Last Post: 12-11-08, 11:42 PM -
Recommend a simple gif creator?
By D-Mac in forum Affiliate Marketing LoungeReplies: 3Last Post: 28-05-08, 04:22 PM -
php, image upload, resize, resample and crop
By morleymouse in forum ProgrammingReplies: 2Last Post: 11-01-06, 09:59 PM -
Photo upload and rating script?
By stevenm in forum ProgrammingReplies: 1Last Post: 16-12-05, 02:33 AM


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks