minnieadkins 0 Report post Posted January 18, 2006 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. Share this post Link to post Share on other sites
vujsa 0 Report post Posted January 18, 2006 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.phpAll 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 Share this post Link to post Share on other sites
Hercco 0 Report post Posted January 20, 2006 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. Share this post Link to post Share on other sites