In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces to you what is the solution to the failure of remote picture upload in UEditor editor, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Remote image upload is a very interesting thing, for example, if you copy a file from another website, if there is a picture in the text, the editor will automatically extract the picture and upload it, so you don't have to worry about the failure of the remote picture. I can't browse locally.
Through inspection, it is found that the operation page for remote image upload is: getRemoteImage.php. After opening it, we first configure savePath, because different users need to store it in different directories to avoid confusion and facilitate management.
Modified code:
The code is as follows:
/ / remote image capture configuration
If (isset ($_ SESSION ['admin'])) {
$myPath = 'https://www.jb51.net/../dofiles/ueditorUpload/admin/'.$_SESSION['admin']['id'].'/';
} else if (isset ($_ SESSION ['user'])) {
$myPath = 'https://www.jb51.net/../dofiles/ueditorUpload/user/'.$_SESSION['user']['id'].'/';
} else {
$myPath = 'https://www.jb51.net/../dofiles/ueditorUpload/unkonw/';
}
$config = array (
"savePath" = > $myPath, / / Save path
"allowFiles" = > array (".gif", ".png", ".jpg", ".jpeg", ".bmp"), / / files allow format
"maxSize" = > 3000 / / File size limit (in KB)
);
Then the problem arises. In UEditor, files and pictures are uploaded through the php class Uploader.class.php, but remote image uploads are not.
I found in line 85 that when creating a path, we simply use mkdir to create it, because mkdir cannot create a path with a hierarchy, so if the path does not exist, copying and uploading the remote image fails.
Knowing that the problem is easy to deal with, I'll write a function that loops to create a file directory (because I've written it before, I'll use it here):
The code is as follows:
/ / continuously create hierarchical folders
Function recursive_mkdir ($folder) {
$folder = preg_split ("/ [\ /] /", $folder)
$mkfolder =''
For ($iTun0; isset ($folder [$I]); $iTunes +) {
If (! strlen (trim ($folder [$I])) {
Continue
}
$mkfolder. = $folder [$I]
If (! is_dir ($mkfolder)) {
Mkdir ("$mkfolder", 0777)
}
$mkfolder. = DIRECTORY_SEPARATOR
}
}
Then modify 85 lines:
The 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 will be no problem.
This issue has also been submitted to Baidu officials, hoping to correct it.
The test UEditor version is 1.2.3.0, if there are related problems in the previous version, it should also be solved to modify it according to the modification idea.
On the UEditor editor remote picture upload failed solution is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.