Resolution on Ueditor Editor remote picture upload failure _php Tutorial

Source: Internet
Author: User
Tags php class
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 the remote image upload Operation page is: getremoteimage.php. After opening we first configure Savepath, because different users, need to store to a different directory, so as to avoid confusion, but also easy to manage

Modified code:

Copy CodeThe code is as follows:
Remote Capture 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 allowed format
"MaxSize" = 3000//File size limit, in kilobytes
);


Then the problem came, ueditor, files, pictures uploaded by Uploader.class.php this PHP class operation, but the remote image upload is not.

I found in line 85 that when I created the path, I simply used mkdir to create it, because mkdir cannot create a path with a hierarchy, so copying a remote picture upload fails if the path does not exist.

Knowing the problem is easy to deal with, I'll start by writing a function that loops through the creation of a file directory (because it was written before, it's used directly here):

Copy CodeThe code is as follows:
Create a folder with hierarchies consecutively
function Recursive_mkdir ($folder) {
$folder = Preg_split ("/[\\\\\/]/", $folder);
$mkfolder = ";
for ($i =0; Isset ($folder [$i]); $i + +) {
if (!strlen (Trim ($folder [$i])) {
Continue
}
$mkfolder. = $folder [$i];
if (!is_dir ($mkfolder)) {
mkdir ("$mkfolder", 0777);
}
$mkfolder. = Directory_separator;
}
}

Then modify the 85 lines:
Copy CodeThe code is 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 the official Baidu, hoping to amend.

Test Ueditor version 1.2.3.0, if the previous version also has related problems, according to modify the idea to modify should also be resolved.

http://www.bkjia.com/PHPjc/325896.html www.bkjia.com true http://www.bkjia.com/PHPjc/325896.html techarticle 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 image, upload, from ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.