jQuery-File-Upload
jQuery-File-Upload copied to clipboard
how to block the display other files (php, html) than images
Thank you, great project
I use jQuery File Upload User Interface Plugin 6.6.2
but displays the files type: php, html
I'm setting jquery.fileupload-ui.js previewSourceFileTypes: /^image/(gif|jpeg|png)$/,
.htaccess ForceType application/octet-stream ...FilesMatch...gif|jpe?g|png... ForceType none ...FilesMatch...
how to block the display other files (php, html) than images
how to use the code to display only photos:
<?php
$dir = './server/php/files/';
$imagesExtensions = array('jpg', 'jpeg', 'gif', 'png');
$folder = scandir($dir);
foreach($folder AS $photos) {
$fileinfo = pathinfo($photos);
if(in_array($fileinfo['extension'], $imagesExtensions)) {
//print_r($photos);
}
}
?>
in upload.class.php
protected function get_file_object($file_name)
or
protected function get_file_objects()
... scandir($this->options['upload_dir']) ...
:|
Hi, it solved the problem
add upload.class.php
protected function get_file_object($file_name)
// add code - Display File Types - variables
$imagesExtensions = array('jpg', 'jpeg', 'gif', 'png', 'JPG', 'JPGE', 'GIF', 'PNG');
$fileinfo = pathinfo($file_path);
// add code - Display File Types - if
// && (in_array($fileinfo['extension'], $imagesExtensions))
all function code
protected function get_file_object($file_name) {
$file_path = $this->options['upload_dir'].$file_name;
// add code - Display File Types - variables
$imagesExtensions = array('jpg', 'jpeg', 'gif', 'png', 'JPG', 'JPGE', 'GIF', 'PNG');
$fileinfo = pathinfo($file_path);
// add code - Display File Types - if
// && (in_array($fileinfo['extension'], $imagesExtensions))
if (is_file($file_path) && $file_name[0] !== '.' && (in_array($fileinfo['extension'], $imagesExtensions)) ) {
$file = new stdClass();
$file->name = $file_name;
$file->size = filesize($file_path);
$file->url = $this->options['upload_url'].rawurlencode($file->name);
foreach($this->options['image_versions'] as $version => $options) {
if (is_file($options['upload_dir'].$file_name)) {
$file->{$version.'_url'} = $options['upload_url']
.rawurlencode($file->name);
}
}
$this->set_file_delete_url($file);
return $file;
}
return null;
}
good luck ;)