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:
Copy Code code as follows:
Remote Crawl picture configuration
if (isset ($_session[' admin ')) {
$myPath = ' http://www.jb51.net/../dofiles/ueditorUpload/admin/'. $_session[' admin ' [' id ']. ' /';
}else if (isset ($_session[' user ')) {
$myPath = ' http://www.jb51.net/../dofiles/ueditorUpload/user/'. $_session[' user ' [' id ']. ' /';
}else{
$myPath = ' http://www.jb51.net/../dofiles/ueditorUpload/unkonw/';
}
$config = Array (
"Savepath" => $myPath,//save path
"Allowfiles" => Array (". gif", ". png", ". jpg", ". jpeg", ". bmp"),//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):
Copy Code code as follows:
Create a folder with layers continuously
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:
Copy Code code as follows:
Create a Save location
$savePath = $config [' Savepath '];
if (!file_exists ($savePath)) {
Recursive_mkdir ($savePath);
mkdir ("$savePath", 0777);
}
In this way, there is no problem.
This issue has also been submitted to Baidu official, hope to amend.
Test Ueditor version of 1.2.3.0, if the previous version also has related problems, according to modify the idea to modify should also be able to solve.