Welcome Guest ( Log In | Register )




                Web Hosting

 
Reply to this topicNew 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 topicNew Topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   8 vizskywalker 4,766 7th January 2009 - 03:11 AM
Last post by: iG-Waseem
No New Posts   11 sendto 6,972 26th December 2008 - 12:59 PM
Last post by: iG-nwaynge
No New Posts   4 CiaraMarie 2,186 23rd December 2008 - 08:24 PM
Last post by: iG-Lucky
No New Posts   5 bridgebuilder 1,678 23rd December 2008 - 06:47 PM
Last post by: pyost
No new   26 iciclez 3,307 21st December 2008 - 10:30 AM
Last post by: Quatrux
No New Posts   15 rmdort 4,477 20th December 2008 - 05:38 AM
Last post by: laniczech
No New Posts   1 veerumits 173 5th December 2008 - 09:16 PM
Last post by: iG-James
No new 41 loca_mami13 4,673 11th November 2008 - 07:01 PM
Last post by: Guest
No New Posts   10 TavoxPeru 789 6th November 2008 - 05:26 AM
Last post by: TavoxPeru
No New Posts   0 veerumits 213 23rd October 2008 - 09:58 PM
Last post by: veerumits
No New Posts   0 TavoxPeru 189 14th October 2008 - 05:18 AM
Last post by: TavoxPeru
No New Posts   1 suicide 1,388 12th October 2008 - 04:24 PM
Last post by: FirefoxRocks
No New Posts   6 pat23 5,166 30th September 2008 - 05:32 AM
Last post by: Jezstarr
No New Posts   18 Killer008r 3,528 10th September 2008 - 02:08 AM
Last post by: Guest
No New Posts   2 soleimanian 4,811 7th August 2008 - 10:58 PM
Last post by: Guest