Hi, after I integrated ckEditor with ckFinder, the upload function is helpful to me. But I still want to revise it a little bit. I don't wanna use original file name and hope to give every uploaded file an unique name (using uniqid() function of PHP) so that I can avoid many problems when uploading a file especially for Chinese file name. I added some script in /CommandHandler/FileUpload.php around line 144:
$path_parts = pathinfo($sFileName);
$sFileName = uniqid() . '.' . $path_parts['extension'];
After this , I can upload files with Chinese name successfully. But here comes a weird problem.
After the file is uploaded, ckEditor will change to default tab "image info" and get the path of uploaded file automatically, but the "URL" field still display "original name"! That means this file doesn't exist anymore.
Could you please help me fix this problem? I've spent almost whole day to figure it out but in vain.
Any solution will be appreciated. Thanks!
$path_parts = pathinfo($sFileName);
$sFileName = uniqid() . '.' . $path_parts['extension'];
After this , I can upload files with Chinese name successfully. But here comes a weird problem.
After the file is uploaded, ckEditor will change to default tab "image info" and get the path of uploaded file automatically, but the "URL" field still display "original name"! That means this file doesn't exist anymore.
Could you please help me fix this problem? I've spent almost whole day to figure it out but in vain.
Any solution will be appreciated. Thanks!
Re: Replace uploaded file name with an unique name
Woops, I found a solution by myself.
Need to revise following file at line 58:
/ckfinder/core/connector/php/php5/CommandHandler/FileUpload.php
$path_parts = pathinfo($uploadedFile['name']);
$ext = strtolower($path_parts['extension']);
$uploadedFile['name'] = uniqid() . ‘.’ . $ext;