TinyMCe bych doporucil.
Nevim, jaky problem mas s uploadem. Mozna to ocekava nejaky plugin, ta free verze.
Aspon stary FCK nemel defaultne nastaveny upload. Pokud tam tedy v adresarich ty soubory na upload jsou (find text = move_uploaded_file), tak to treba nejspis jen nastavit v configu na php upload a zadat spravne cesty root adresarum. V fck jsem odnekud ten plugin ziskal, ale musel jsem ho cely prepsat. Pocital tam s cestou k webu, kdy je primo / = root = /editor/. Kdezto na hostingu je root adresar / nastaveny jen jako root hostingu. cili, ty mas stranky pod /var/www/moje/editor/. Coz potom je cesta blbe. Mno, nakonec jsem tam udelal asi 3 ruzne cesty misto 1 a v celem pluginu to poprepisoval
Jinak, vypis souboru mas
$skip = array();
$dirhandle = opendir($path);
while (($name=readdir($dirhandle)) !== false) // adresar name='0'
{
if (in_array($name,$skip))
{
continue;
}
if (is_dir($path.$name))
{
$out['dirs'][] = $name;
continue;
}
$out['files'][] = $name;
}
closedir($dirhandle);
//var_dump($out['files']);
Upload je trochu slozitejsi. Mam to provazane na nekolik class, tak to sem davat nebudu cele. A tahle cast je jeste netetovana. Zrovna ty odzkousene verze mam na jinem pc...
class classFileUpload
{
var $cfg, $lock_status, $input_all, $file_all;
function __construct()
{
$this->cfg = array(
'root' => '',
'lock_path' => './actual/',
'lock_file' => 'lock.txt',
'log_file' => 'log.txt'
);
$this->lock_status = array(
'locked' => 'locked',
'unlocked' => 'unlocked'
);
$this->tmp_all = array();
$this->file_all = array();
}
public function errFn($name)
{
return 'classFileUpload::'.$name.': ';
}
public function fileClearPath($path)
{
return preg_replace('~^\.+\/+()|\.+(\/)+|(\/)\/+~',"$2",$path); // odstran ./ ../ ///
}
public function inputRead($input_name='')
{
$err_fn = $this->errFn('inputRead');
$input_field = isset($_FILES[$input_name]) ? $_FILES[$input_name] : (isset($HTTP_POST_FILES[$input_name]) ? $HTTP_POST_FILES[$input_name] : '');
if (isset($input_field['tmp_name']) && is_uploaded_file($input_field['tmp_name']))
{
$file = $input_field['tmp_name']
$this->input[] = $file;
return $file;
}
fce_notice($err_fn.'No file is uploaded!','error');
return false;
}
public function fileCopy($path_from, $path_to)
{
$fp1 = fopen($path_from, "r");
$data1 = fread($fp1, filesize($path_from));
fclose($fp1);
$this->fileWrite($path_to, $data1);
}
public function fileWrite($file_name, $data, $opt=array()) //, $file_pos_line=0
{
$err_fn = $this->errFn('fileWrite');
$opt = array(
'end_time' => 5000, // 5000 ms
'type' => 'w', // !!! ZMENIT na w nebo w+
'dir_chmod' => 0777,
'file_chmod' => 0755
);
$old = umask(0); // https://www.tutorialspoint.com/…rmission.htm
// @chmod($dir,$opt['dir_chmod']); // !!! UPRAVIT kod, pokud budes chtit pouzit | nastav prava adresare na 0777
$fp = fopen($file_name, $opt['type']);
if ($fp === false)
{
umask($old);
fce_notice($err_fn.'Cannot open file '.$file_name.'.', 'error');
return false;
}
// cekej na locknuti 5000 ms, zkousej to kazdych 0 - 100 ms
$can_write = false;
$i = microtime();
$i_end = $i + $opt['end_time'];
while (!$can_write && microtime()<$i_end);
{
$can_write = flock($fp, LOCK_EX); // lock
if (!$can_write)
{
usleep(round(rand(0,100)*1000)); // micro-second
}
}
if ($can_write === false)
{
umask($old);
fclose($fp);
fce_notice($err_fn.'Cannot unlock file '.$file_name.'.', 'error');
return false;
}
// fseek($fp, $file_pos_line); // !!! zakomentovat
fwrite($fp, $data);
flock($fp, LOCK_UN); // unlock
fclose($fp);
@chmod($file_name, $opt['file_chmod']); // !nastavit prava k zapisu souboru, 0755 (rwx r.x r.x) nebo 644 (rw. r.. r..) (owner-vlastnik, group-skupina, other-ostatni, r-read, w-write, x-execute; umask, mkdir)
umask($old);
return true;
}
public function fileRead($name)
{
if (file_exists($name))
{
$data = file_get_contents($name);
return $data;
}
return false;
}
public function fileMove($path_from='', $path_to='', $rewrite=false)
{
$err_fn = $this->errFn('fileMove');
if ($rewrite==true || !file_exists($path_to))
{
$old = umask(0);
@chmod($file_path,0777); // nastav prava adresare na 777 !nebezpecne
$bool = move_uploaded_file($path_from, $path_to) || copy($path_from, $path_to) || $this->fileCopy($path_from, $path_to);
if ($bool!==false)
{
fce_notice($err_fn.'Soubor uploadovan.','');
}
else {
fce_notice($err_fn.'Cannot move file from "'. $path_from .'" to "'. $path_to .'". Check file permitions.', 'error');
}
@chmod($to,0444); // https://www.tutorialspoint.com/…rmission.htm
umask($old);
return $bool;
}
fce_notice($err_fn.'Cannot move file. File "'.$path_to.'" is exist!', 'error');
return false;
}
public function upload($input_name, $file_path, $rewrite=false) // NORMAL UPLOAD
{
$err_fn = $this->errFn('upload');
$path_from = $this->inputRead($input_name);
if ($path_from===false)
{
return false;
}
return $this->fileMove($path_from, $path_to);
}