NYCPHP Meetup

NYPHP.org

[nycphp-talk] File upload form (was: Re: (no subject))

CED Consult at CovenantEDesign.com
Sat Sep 16 22:48:40 EDT 2006


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






More information about the talk mailing list