Remote image upload is a very interesting thing, such as you copy a file from another site, if the text with a picture, the editor will automatically extract the picture, upload, so do not worry about the remote image after the failure of their own local can not browse.
Through the check, found that the remote Picture Upload action page is: getremoteimage.php. After opening, we first configure the Savepath, because different users need to be stored in a different directory, so as to avoid confusion, but also easy to manage
Modified code:
The code is as follows |
Copy Code |
?//remote capture picture configuration if (isset ($_session[' admin ')) { $myPath = ' http:///... /dofiles/ueditorupload/admin/'. $_session[' admin ' [' id ']. ' /'; }else if (isset $_session[' user ')) { $myPath = ' http:///... /dofiles/ueditorupload/user/'. $_session[' user ' [' id ']. ' /'; }else{ $myPath = ' http:///. /dofiles/ueditorupload/unkonw/'; } $config = Array ( "Savepath" => $myPath, //save path "Allowfiles" => Array (". gif", ". png", ". jpg", ". jpeg", ". MP "),//file Allow format " MaxSize "=> 3000 //File size limit, per KB ); |
Then the problem comes, ueditor, file, picture upload is through Uploader.class.php this PHP class operation, but the remote picture upload is not.
I found in line 85, creating the path, simply using the mkdir to create, because the mkdir can not create a hierarchical path, so that if the path does not exist, replication of remote picture upload failed.
Knowing the problem is easy, I'm going to write a loop to create the file directory (because I've written it before and it's used here directly):
?//Create a folder with levels continuously
The code is as follows |
Copy Code |
function Recursive_mkdir ($folder) { $folder = Preg_split ("/[\\/]/", $folder); $mkfolder = '; For ($i =0 isset ($folder [$i]); $i + +) { if (!strlen ($folder [$i])) { Continue } $mkfolder. = $folder [$i]; if (!is_dir ($mkfolder)) { mkdir ("$mkfolder", 0777); } $mkfolder. = Directory_separator; } }
|
Then modify the 85 lines:
?//Create Save location
The code is as follows |
Copy Code |
$savePath = $config [' Savepath ']; if (!file_exists ($savePath)) { Recursive_mkdir ($savePath); mkdir ("$savePath", 0777); }
|