KCFinder issue with PDF uploads - php

I am trying to use standalone KCFinder to upload PDF files and images. Just downloaded the zip from their website and started to build up the "system" and it works perfect with images. The problem is when I want to upload PDF files, I get an error: "Unknown image format/encoding".
NOTE: When I open my KCFinder standalone it is already on the folder "images" and not "upload". I know this can be the cause but I can't find out how to change this...
Here is my config.php:
$_CONFIG = array(
// GENERAL SETTINGS
'browse.php?lang'=>sv,
'disabled' => false,
'theme' => "oxygen",
'uploadURL' => "upload",
'uploadDir' => "",
'types' => array(
// (F)CKEditor types
'files' => "",
'flash' => "swf",
'images' => "*img",
'misc' => "pdf doc docx xls xlsx",
// TinyMCE types
'file' => "",
'media' => "swf flv avi mpg mpeg qt mov wmv asf rm",
'image' => "*img",
),
// IMAGE SETTINGS
'imageDriversPriority' => "imagick gmagick gd",
'jpegQuality' => 90,
'thumbsDir' => ".thumbs",
'maxImageWidth' => 0,
'maxImageHeight' => 0,
'thumbWidth' => 100,
'thumbHeight' => 100,
'watermark' => "",
// DISABLE / ENABLE SETTINGS
'denyZipDownload' => false,
'denyUpdateCheck' => false,
'denyExtensionRename' => false,
// PERMISSION SETTINGS
'dirPerms' => 0755,
'filePerms' => 0644,
'access' => array(
'files' => array(
'upload' => true,
'delete' => true,
'copy' => true,
'move' => true,
'rename' => true
),
'dirs' => array(
'create' => true,
'delete' => true,
'rename' => true
)
),
'deniedExts' => "exe com msi bat php phps phtml php3 php4 cgi pl",
// MISC SETTINGS
'filenameChangeChars' => array(/*
' ' => "_",
':' => "."
*/),
'dirnameChangeChars' => array(/*
' ' => "_",
':' => "."
*/),
'mime_magic' => "",
'cookieDomain' => "",
'cookiePath' => "",
'cookiePrefix' => 'KCFINDER_',
// THE FOLLOWING SETTINGS CANNOT BE OVERRIDED WITH SESSION SETTINGS
'_check4htaccess' => true,
//'_tinyMCEPath' => "/tiny_mce",
'_sessionVar' => &$_SESSION['KCFINDER'],
//'_sessionLifetime' => 30,
//'_sessionDir' => "/full/directory/path",
//'_sessionDomain' => ".mysite.com",
//'_sessionPath' => "/my/path",
);
Does anyone know what I am doing wrong?

dont use insert image. if you want to upload file (zip pdf .etc), you must use INSERT LINK rather than INSERT IMAGE.
but before, you must edit the config.
'types' => array(
// CKEditor & FCKEditor types
'files' => "",
'flash' => "swf",
'images' => "*img",
// TinyMCE types
'file' => "doc pdf zip", // <<<======= HERE, because iam using tinyMCE
'media' => "swf flv avi mpg mpeg qt mov wmv asf rm",
'image' => "*img",
)

1.I download the ckeditor "Standard Package".
2.I download the add-ons "File Browser" and "Popup" from the add-ons part of ckeditor.com.
3.I set the config in "ckeditor/config.js",
config.extraPlugins = 'popup,filebrowser';

Related

Laravel video upload - issue with ios device, mime-type application/octet-stream

I created an API to upload videos.
when I upload a video from postman its works fine
but when I use the same API with ios device file extension missing.
Request from POSTMAN
array (
'post_id' => '25',
'file' =>
Illuminate\Http\UploadedFile::__set_state(array(
'test' => false,
'originalName' => 'IMG_5190.MOV',
'mimeType' => 'video/quicktime',
'error' => 0,
'hashName' => NULL,
)),
)
Request from IOS
array (
'post_id' => '5331',
'file' =>
Illuminate\Http\UploadedFile::__set_state(array(
'test' => false,
'originalName' => 'phpKz6dKN',
'mimeType' => 'application/octet-stream',
'error' => 0,
'hashName' => NULL,
)),
)
File Upload Code
$file = $request->file('file');
$ext = $file->getclientoriginalextension() ? $file->getclientoriginalextension() : 'mov';
$size = $file->getSize();
$filename = Str::random(100) . date('his').'.'.$ext;
$localVideo = Storage::disk('public')->put($filename, file_get_contents($file));
So I just added an extension .mov if there is none.
someone please guide me to proper way to upload 'mimeType' => 'application/octet-stream' type files.
it is problem in your php.ini file. max_file_size.

Open FTP files in elFinder without giving details

I am using elFinder for manage my FTP files. But I want to open FTP files and folders without giving FTP details. I keep elFinder files on same FTP. Is it possible?
In connector.php:
$opts = array(
// 'debug' => true,
'roots' => array(
array(
'driver' => 'FTP',
'path' => 'here i give path of folder',
'accessControl' => 'access' ,
'tmpPath' => '../files/ftp',// disable and hide dot starting files (OPTIONAL)
'defaults' => array('read' => true, 'write' => true),
'disabled' => array('rename', 'rm' , 'copy' ,'cut','paste')
)
)
);
but when I used this. I get this error:
Invalid backend configuration. Readable volumes not available.
I found the solution for this.To open files we dont need to use ftp option in driver just use localfilesystem and give path of files according to server.
$opts = array(
// 'debug' => true,
' roots' => array(
array(
'driver' => 'localFileSystem',
'path' => 'path of the folder that you want to browse',
'accessControl' => 'access' ,
'defaults' => array('read' => true, 'write' => true),
'disabled' => array('rename', 'rm' , 'copy' ,'cut','paste')
)
)
);

Drupal 7.31 - Problems with file type field of node

I have created some custom page on frontend for particular type of node modyfications. Here's my page callback:
function vintranet_talk_edit_entry_page_callback($sNid) {
module_load_include('inc', 'node', 'node.pages');
$oNode = node_load($sNid);
return drupal_get_form('page_node_form', $oNode);
}
My node has one field with file attachments.
Config:
'vintranet_talk_attachments' => array(
'field_name' => 'vintranet_talk_attachments',
'label' => t('Attachments'),
'type' => 'file',
'cardinality' => -1,
),
Instance:
'vintranet_talk_attachments' => array(
'field_name' => 'vintranet_talk_attachments',
'label' => t('Attachments'),
'entity_type' => 'node',
'bundle' => 'intranet_talk_page',
'widget' => array(
'type' => 'file_mfw',
),
'settings' => array(
'max_filesize' => 10,
'file_directory' => 'intranet/talk',
'file_extensions' => 'jpg, png, gif, pdf, zip, doc, rtf, xdoc, rar',
'description_field' => 1,
),
'display' => array(
'default' => array(
'type' => 'file_table',
),
),
),
My first problem is, when I want to upload JPG file after module installation, system sends me this message:
So ok... I'm going to check that particular field settings in Structure and I see this:
Why the hell it is saved like this?!
Okaaaaay.... so I'm changing this form field value on jpg, png, gif, pdf, zip, doc, rtf, xdoc, rar, saving and trying to upload the image one more time...
....clickin "Upload" button.... aaaaandd....
....yup.... that's my 2nd problem :/. Have no idea why it's not working. On the backend, in other hand, the "Upload" button works perfectly. Am I missing something?
(working on Drupal 7.31 version)
Menu node add path:
array(
'mynode/add/path' => array(
'title' => 'Title - new entry',
'page callback' => 'vintranet_talk_add_entry_page_callback',
'file' => 'vintranet_talk.pages.inc',
'access arguments' => array('vintranet_talk_add_entry'),
),
);
Answer for my problems:
function hook_menu_alter(&$aItems) {
$sNodePath = drupal_get_path('module', 'node');
$aItems['file/ajax']['file path'] = $sNodePath;
$aItems['file/ajax']['file'] = 'node.pages.inc';
$aItems['system/ajax']['file path'] = $sNodePath;
$aItems['system/ajax']['file'] = 'node.pages.inc';
}

Not able to restrict other files from uploading in ElFinder

I am using this configuration for my Elfinder to use with CKEditor.
$opts = array(
// 'debug' => true,
'roots' => array(
array(
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => '../../uploads/', // path to files (REQUIRED)
'URL' => dirname($_SERVER['PHP_SELF']) . '/../../uploads/', // URL to files (REQUIRED)
'accessControl' => 'access' , // disable and hide dot starting files (OPTIONAL)
'uploadAllow' => array('image/jpg', 'image/png'),
'alias' => 'Home',
'mimeDetect' => 'internal',
'imgLib' => 'gd',
),
),
);
However, I am able to upload all the files even PHP files!! I only want images to be uploaded. I am not able to restrict the uploading. Where am I going wrong?
Add:
'uploadOrder'=> array( 'allow', 'deny' )
Without this the default policy is allow if none of them matches.
According to:
https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options#wiki-uploadOrder

KCFinder - browse.php downloading rather than displaying page

I've integrated the latest version of KCFinder into CKEditor - whenever I click the 'Browse Server' button on the CKEditor toolbar it opens the KCFinder dialog box and downloads the 'browse.php' file rather than display the contents of a directory.
It is almost as if for some reason the PHP engine stops working temporarily - i've not modified any of the htaccess files.
I'm currently using the standard config.php within the kcfinder directory - would anyone know what may have caused this and how to fix it?
// kcfinder/config.php
$_CONFIG = array(
'disabled' => true,
'denyZipDownload' => false,
'denyUpdateCheck' => false,
'denyExtensionRename' => false,
'theme' => "oxygen",
'uploadURL' => "",
'uploadDir' => "",
'dirPerms' => 0755,
'filePerms' => 0644,
'access' => array(
'files' => array(
'upload' => true,
'delete' => true,
'copy' => true,
'move' => true,
'rename' => true
),
'dirs' => array(
'create' => true,
'delete' => true,
'rename' => true
)
),
'deniedExts' => "exe com msi bat php phps phtml php3 php4 cgi pl",
'types' => array(
// CKEditor & FCKEditor types
'files' => "",
'flash' => "swf",
'images' => "*img",
// TinyMCE types
'file' => "",
'media' => "swf flv avi mpg mpeg qt mov wmv asf rm",
'image' => "*img",
),
'filenameChangeChars' => array(/*
' ' => "_",
':' => "."
*/),
'dirnameChangeChars' => array(/*
' ' => "_",
':' => "."
*/),
'mime_magic' => "",
'maxImageWidth' => 0,
'maxImageHeight' => 0,
'thumbWidth' => 100,
'thumbHeight' => 100,
'thumbsDir' => ".thumbs",
'jpegQuality' => 90,
'cookieDomain' => "",
'cookiePath' => "",
'cookiePrefix' => 'KCFINDER_',
// THE FOLLOWING SETTINGS CANNOT BE OVERRIDED WITH SESSION CONFIGURATION
'_check4htaccess' => true,
//'_tinyMCEPath' => "/tiny_mce",
'_sessionVar' => &$_SESSION['KCFINDER'],
//'_sessionLifetime' => 30,
//'_sessionDir' => "/full/directory/path",
//'_sessionDomain' => ".mysite.com",
//'_sessionPath' => "/my/path",
);
?>
I got the same problem and I found that the .htaccess file in the kcfinder dir was precisely shut the php engine off. I removed the .htaccess file and then it worked. I do not understand why this shutting off was necessary. Security??
Well, I still get a problem to point at the right directory, but now I see something !!
One comment here about the CONFIG array here above. The attribute disabled have to be put to false, and it is often suggested to be done through a SESSION variable (put $_SESSION['KCFINDER'] = array();
$_SESSION['KCFINDER']['disabled'] = false; after the session_start() ), and not directly in the config file.

Categories