Welcome Guest ( Log In | Register )




                Web Hosting Guide

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
 
New Topic
Replies (1 - 2)
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   10 mastercomputers 367 19th February 2010 - 07:42 AM
Last post by: Quatrux
No New Posts   5 jackpinerepublic 4,400 19th February 2010 - 02:04 AM
Last post by: iG-Simon Varley
No New Posts   3 nntien 1,420 17th February 2010 - 07:23 PM
Last post by: iG-Damian
No New Posts   7 Eggie 163 15th February 2010 - 10:34 PM
Last post by: Nelson Blogs
No new   71 BooZker 44,906 12th February 2010 - 01:45 PM
Last post by: iG-pradeep
No New Posts   13 vizskywalker 6,261 31st January 2010 - 11:57 PM
Last post by: iG-Itsa Himitsu
No New Posts   0 8ennett 71 30th January 2010 - 11:10 PM
Last post by: 8ennett
No New Posts   6 shiv 4,412 14th January 2010 - 02:47 PM
Last post by: iG-Johnathan
No New Posts   15 sendto 15,317 26th December 2009 - 07:16 AM
Last post by: iG-
No New Posts   11 vizskywalker 11,508 18th December 2009 - 03:15 PM
Last post by: iG-Christian Cawley
No new   31 rmdort 14,334 9th December 2009 - 05:51 AM
Last post by: iG-ash
No new   23 TavoxPeru 13,135 6th December 2009 - 01:38 PM
Last post by: iG-Alex Finney
No New Posts   2 Dominus 4,761 28th November 2009 - 11:05 PM
Last post by: iG-Shayan Imani
No New Posts   12 avalon 4,862 23rd October 2009 - 10:15 AM
Last post by: iG-kkk
No New Posts   2 gerhard 2,606 1st October 2009 - 01:15 PM
Last post by: iG-anu


Web Hosting Powered by ComputingHost.com.
HONESTY ROCKS! truth rules.
Creative Commons License