WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-24-2008, 08:27 AM
dux dux is offline
WebProWorld Member
 

Join Date: Jan 2007
Location: Manchester, England
Posts: 64
dux RepRank 0
Default Need help using PHP to upload images and collecting data from a form

I am building a new website that allows members to upload images. I am using a program called Gallery to build the site (I have got it working and set the site up). I have located a php script that allows users to upload an image. The form they need to complete will be very simple, but I want it to include their username without the need for manual input. The images will be uploaded directly to the server so I need to match up an image with the user who submitted it as there will be other information in the form that needs to be added alongside the image.

My question is; how do I do it?

I have been looking at cookies or sessions, but I could really do with some advice on the whole process.

I am also a little wary about security. The upload folder is password protected but I really think I should be doing more than just that. How can I protect myself against viruses etc?

Any help on this would be greatly appreciated, it is very much a work in progress at the moment....

EDIT - I have been thinking about this - could the ouput of the form create a html file containing the image and the form fields?

Last edited by dux : 02-24-2008 at 08:58 AM.
Reply With Quote
  #2 (permalink)  
Old 02-24-2008, 08:36 AM
purplepaisley purplepaisley is offline
WebProWorld New Member
 

Join Date: Dec 2005
Location: UK
Posts: 16
purplepaisley RepRank 0
Default Re: Need help using PHP to upload images and collecting data from a form

Hi, just my 2 cents but why reinvent the wheel when you can use something like Coppermine Gallery which does this already and has a very active open source community which maintains code security and compatibilty updates.
__________________
Open Source CMS Integrations & Customisations *website under development*
(Dokuwiki / Simple Machines Forum / Drupal)
Reply With Quote
  #3 (permalink)  
Old 02-24-2008, 08:53 AM
dux dux is offline
WebProWorld Member
 

Join Date: Jan 2007
Location: Manchester, England
Posts: 64
dux RepRank 0
Default Re: Need help using PHP to upload images and collecting data from a form

I had a look at CopperMine but there was something about it I didn't like, and I can't remember what that was right now.

Last edited by dux : 02-24-2008 at 10:21 AM.
Reply With Quote
  #4 (permalink)  
Old 02-25-2008, 05:38 PM
niggles niggles is offline
WebProWorld Member
 

Join Date: Oct 2005
Posts: 29
niggles RepRank 1
Default Re: Need help using PHP to upload images and collecting data from a form

If you're going to allow visitors to upload images, you can either use a third party script (like Coppermine) or have a good read of PHP documentation. PHP.net has a wealth of information and script snippets.

At the very minimum you're going to need to understand:

* $_SESSION for associating the username they've logged in with the image so you can write it to the database or rename it

* mime type checking to ensure that they don't upload an .exe or .php instead of a .jpg (it's no good just checking the extension)

* renaming the files once uploaded so they don't contain malicious characters


The process is not so hard, but to be security conscious it's worth doing some reading on how to prevent file upload attacks etc.

Cheers,
Nigel
__________________
-------------------------------------------------
World Music World - bringing the World's Folk Music Cultures Together
http://www.worldmusicworld.com/
-------------------------------------------------
Reply With Quote
  #5 (permalink)  
Old 02-25-2008, 06:06 PM
memaggiem memaggiem is offline
WebProWorld Member
 

Join Date: Apr 2004
Location: N.E.
Posts: 39
memaggiem RepRank 0
Default Re: Need help using PHP to upload images and collecting data from a form

I hope I can say this - I browsed around, found a script that I was pleased with but it wasn't really what I wanted and it took some time to implement for what I wanted to do. I have multiple forms and multiple uploads of different types.

I browsed and tinkered more and then just got CoffeeCup form builder. (Can I say this - the company that is? I guess we'll see!) I'm pleased with it and have had no security issues at all.

HTH
Maggie
Reply With Quote
  #6 (permalink)  
Old 02-26-2008, 04:59 AM
datetopia's Avatar
datetopia datetopia is offline
WebProWorld Pro
 

Join Date: Dec 2006
Location: Datetopia Dating Software
Posts: 102
datetopia RepRank 0
Default Re: Need help using PHP to upload images and collecting data from a form

If don't have php programming experience you should hire a programmer or start with some tutorials:
PHP Tutorial - File Upload
Reply With Quote
  #7 (permalink)  
Old 02-26-2008, 08:44 AM
alhefner alhefner is offline
WebProWorld Member
 

Join Date: Jan 2008
Location: Reno, Nevada
Posts: 89
alhefner RepRank 1
Default Re: Need help using PHP to upload images and collecting data from a form

I guess I am missing something here. Gallery is pretty secure on it's own and has a huge upload capability with file checking built in.

Do you want your gallery users to have direct access to your server ftp? I would never recommend that route!

Also, coppermine has pretty much the same capability just presented differently.

If you are attempting to go a simpler route that using the built-in functions of Gallery, you really do need to learn PHP! Using the super global variables like $_POST and $_SESSION are tools that every webmaster using PHP should know anyway. It will help you avoid those huge URL's that search engines don't like.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Send form data with PHP kurt.santo Web Programming Discussion Forum 13 01-13-2008 03:54 PM
Passing form data to remote form on another site webace Graphics & Design Discussion Forum 8 08-31-2007 03:21 AM
Form data to PDF Tim Web Programming Discussion Forum 15 04-28-2007 01:51 AM
New shopping directory, upload your images or logo Mekchoudi Link Exchange 1 09-26-2006 11:39 AM
Pre-populating an HTML Form with Data from Another HTML Form ambassador Web Programming Discussion Forum 3 06-19-2005 09:12 PM


Search Engine Friendly URLs by vBSEO 3.0.0