[nycphp-talk] File upload form (was: Re: (no subject))
David Krings
ramons at gmx.net
Sun Sep 17 11:38:12 EDT 2006
Hi,
ah yes, but that check is done after the file is already in
temporary storage on the server, means after the HTML form submitted it.
That isn't that difficult and I implemented that for now (although I have
to admit that your code is half of mine and does the same thing). I want to
screen the soon to be uploads before anything gets submitted, which means I
need something that works on the client side. Would be nice to have client
side PHP scripting... :/
Thanks for the short version.
David
At 10:48 PM 9/16/2006, you wrote:
>I may have been thinking of the <FileMAtch> Apache Directive... but I'm
>almost certain a few months ago I dealt with this in the PHP ini file..
>
>
><?php
>$file_types = array(
>'image/pjpeg' => 'jpg',
>'image/jpeg' => 'jpg',
>'image/bmp' => 'bmp',
>);
>if (!array_key_exists($filetype, $file_types)) {
>echo "Oops, filey typey no worky";
>exit;
>}
>else
>{
>$file_dir = "/path/to/upload/directory/place/";
>foreach($_files as $file_name => $file_array) {
>print "path: ".$file_array['tmp_name']."<br>\n";
>print "name: ".$file_array['name']."<br>\n";
>print "type: ".$file_array['type']."<br>\n";
>print "size: ".$file_array['size']."<br>\n";
>if (is_uploaded_file($file_array['tmp_name'])) {
>move_uploaded_file($file_array['tmp_name'], "$file_dir/$file_array[name]")
>or die ("Upload Failed");
>echo 'Uploaded!! Woo Hoo!' ;
>}
>}
>}
>?>
>
>HTH,
>Edward JS Prevost II
>Me at EdwardPrevost.info
>www.EdwardPrevost.info
>
>----- Original Message -----
>From: "David Krings" <ramons at gmx.net>
>To: "NYPHP Talk" <talk at lists.nyphp.org>
>Sent: Saturday, September 16, 2006 9:43 PM
>Subject: Re: [nycphp-talk] File upload form (was: Re: (no subject))
>
>
>That can be done? I guess it can since you mention it as a possible
>solution. This way I can also set the upload limit on the fly and make it
>even configurable. I assume I'd use ini_set() for this? I found the setting
>for the max file uploads and upload limits and execution limits, but which
>setting would restrict the file types allowed for upload. Would such a
>change be reflected in the browse box? My guess it not as that browse box
>is generated by the browser. So what happens when one picks a file with an
>illegal file extension?
>
>Nevertheless, this is awesome!
>
>Thank you!
>
>
>At 07:48 PM 9/16/2006, you wrote:
> >Your best bet is to alter your PHP.ini for specific files to only allow
>them
> >to be uploaded, and or to change that ini setting on the page that is
> >performing the upload and then default it back.
> >
> >HTH,
>
>_______________________________________________
>New York PHP Community Talk Mailing List
>http://lists.nyphp.org/mailman/listinfo/talk
>
>NYPHPCon 2006 Presentations Online
>http://www.nyphpcon.com
>
>Show Your Participation in New York PHP
>http://www.nyphp.org/show_participation.php
>
>
>
>_______________________________________________
>New York PHP Community Talk Mailing List
>http://lists.nyphp.org/mailman/listinfo/talk
>
>NYPHPCon 2006 Presentations Online
>http://www.nyphpcon.com
>
>Show Your Participation in New York PHP
>http://www.nyphp.org/show_participation.php
More information about the talk
mailing list