Use ueditor editor. The attachment is in ueditor/php/upload/ by default. My attachment address is /data/upload/ in the root directory of the website. You need to modify ueditor as follows:
Step 1: Open php /config.php Modify the image directory
return array( //图片目录 'imageSavePath' => array ( '../../../../data/upload' ) );
Step 2: Remove the relative path after uploading the image php/imageUp.php
$info["url"]=str_replace('../../../../', '', $info["url"]); echo "{'url':'" . $info["url"] . "','title':'" . $title . "','original':'" . $info["originalName"] . "','state':'" . $info["state"] . "'}"; exit;
Step 3: Open ueditor.config.js to modify the image path
,imagePath:"/"
Step 4: If you want to modify the image generation path or image name
Modify the image generation path in php/Uploader.class.php
private function getFolder() { $pathStr = $this->config[ "savePath" ]; if ( strrchr( $pathStr , "/" ) != "/" ) { $pathStr .= "/"; } $pathStr .= date( "Ym/d" ); if ( !file_exists( $pathStr ) ) { if ( !mkdir( $pathStr , 0777 , true ) ) { return false; } } return $pathStr; }
Modify the file name in Search "fileNameFormat" in ueditor.all.min.js, and then modify it according to the official documentation!
For more related articles on how to modify the UEditor editor’s custom uploaded image or file path, please pay attention to the PHP Chinese website!