homepage Welcome to WebmasterWorld Guest from 54.166.122.65
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

    
a simple upload page ?
simple upload page
expatCanuck

5+ Year Member



 
Msg#: 3721173 posted 3:55 pm on Aug 12, 2008 (gmt 0)

Greetings.

I'd like to create a simple file upload page, ideally utilizing FTP under the hood ('cause some files transmitted might be large).
Something that'll throw the incoming file into /public_ftp/incoming/.

Any suggestions as to approaches (cgi? php? cPanel widget?), tutorials & sample pages most welcome.

As well, if there are any 'built-ins' in cPanel that I can leverage, I'd appreciate knowing about that. Similarly, if anyone has a sample script that shows how to take advantage of the cPanel's FTP administration, that'd be splendid.

Thanks kindly.

- Richard

 

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3721173 posted 11:18 pm on Aug 12, 2008 (gmt 0)

I'd like to create a simple file upload page, ideally utilizing FTP under the hood ('cause some files transmitted might be large).

I've been doing file uploads from the web for quite some time, and while I'm sure there's a way, I just have never heard of it. If you upload files from a web page, it's going to be via http protocol, not FTP.

The way it works is you start with a multipart form:

<form method="post" enctype="multipart/form-data" action="yourscript.cgi/php/asp">

The enctype is normally left out, but it's required for a file upload. It tells the browser to send the data indistinct parts, normal encoded data and multiple parts for the files, which are transmitted in binary. The tool is the file element:

<input type="file" name="picture_1" id="picture_1">

Which includes a non-editable text area and browse button. It cannot be populated, this is a security feature.

Then your script parses out the multiple parts into plain key/value pairs and the binary data associated with each file element's uploaded contents. Be aware this is something you want to screen and screen accurately - anyone could upload "imivirus.exe", even with a .jpg extension, then request it from the browser.

For this reason, the method I'm most comfortable with is perl, using the CGI module to manage the file upload. It makes it very easy, and CGI.pm is now part of the distribution of perl.

If these uploads involve images, I like to use the module ImageMagick to work with the files. You can use ImageMagick to do all sorts of cool stuff, the most important being resizing images (so your uploaders don't hog up your disk space and break your layouts with huge pics) and in this case, checking the file for a valid image type. You can read in uploaded images with ImageMagick and it will tell you any number of attributes, including color space (RGB, CMYK, etc.) It can read pretty much any file format - TIFF, EPS, jpg, gif, PNG, targa, etc. It it's not a valid image file, delete it and error out.

Because sometimes an extension is just not enough. :-)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / New To Web Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved