Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Uploading Image Via Admin Menu?
minnieadkins
post Jan 18 2006, 10:17 PM
Post #1


Premium Member
Group Icon

Group: Members
Posts: 292
Joined: 15-December 04
Member No.: 1,768



There's never much action in here.

Here's a question for all you php guys out there. Here's what I want. Let's say I create a simple administration menu for someone to Add/Edit/Delete a record/item from a database. Now in the add function, let's say I want to store a URL to a image. Rather than having to go in and FTP that image up on the server, how could a person create a 'Browse' button and find that image on your harddrive, then create a script to upload the image to the server?

Just wondering how to do it, or if it could be done easily. I assume it would be a fairly simple process, but I've never attempted it, and I figured someone out there has. Let me know what are your thoughts and past experiences.
Go to the top of the page
 
+Quote Post
vujsa
post Jan 18 2006, 10:55 PM
Post #2


Absolute Newbie
Group Icon

Group: Admin
Posts: 888
Joined: 20-February 05
From: Indianapolis, Indiana, USA (Midwest)
Member No.: 2,714
myCENTs:35.43



Well, the good news is that the PHP manual has a special section just for this topic.

In fact, the example they give is pretty much the best way to do it as well.

http://us2.php.net/manual/en/features.file-upload.php

All you really need to do is copy and paste the example and fill in your information for it. Of course, extra features can be obtained by using other functions in the script.

Hope this helps, if you need more information or more resouces, let me know and I'll see if I can help.

vujsa
Go to the top of the page
 
+Quote Post
Hercco
post Jan 20 2006, 03:33 PM
Post #3


Super Member
Group Icon

Group: Members
Posts: 595
Joined: 4-September 04
Member No.: 228



Handling file uploads is much easier that you might think. Actually, if you can process typical textual form data, you should be able to process files too.

In exactly similar manner than in a, say post form, the file information exists in a superglobal array $_FILES, just like the superglobals $_POST and $_GET. The array contains the temporary filename for the file from which you can move it to your directory of choise. And that's about it. Then you are free to do whatever processing you wish, such as resizing the image and so on.

Although the file uploads is really easy to do in itself you should pay attention to some issues especially if you are allowing uploads from anyone (so not just your own admin panel that only you have access). In all cases there are limitations on filesize: in PHP a certain maximum size for an uploaded file is set and it can be a real limitation for large images. So if your upload fails you know what to check first.

But more importantly you should pay attention to security... remember you are allowing file uploads to the server! So it is essential that you check that the data is what it is supposed to be and make sure that no malicious person gets his own program code to server. So if you expect images accept only images.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Random Image / Random Header(5)
  2. Forum Signature-image With Php(8)
  3. Php: Write Random Text As Image(3)
  4. Is It Possible To Create A String Image In Chinese(0)
  5. Saving A Php Generated Image To The Server(5)
  6. How Do I Make PHP Based Image Gallery Like This?(20)
  7. How Do I Resize An Image On The Fly?(8)
  8. Script For Viewing A Random Image Needed(3)
  9. Php :: Adding Image Over Image(5)
  10. Image Works With Php And Gd(3)
  11. Php :: Image Pixel Per Inch And Conversion(1)
  12. Should This Great Site Offer Imagemagick ?(3)
  13. Php File Upload(3)
  14. How To Disable Safe Mode In Direct Admin.(1)
  15. Php Uploading Problem(6)
  1. Need Help With Background Image...(12)
  2. Image Popup On Mouseover(23)
  3. Dynamic Gd Image(2)
  4. Dynamic Php Image And Better Php Code Question(10)


 



- Lo-Fi Version Time is now: 2nd December 2008 - 12:18 AM