Xheditor is a message board plug-in, itself with the image upload function, need to Imgurl to the CI controller, but how to write the controller in the relevant code, I directly with the CI upload class and image scaling, but xheditor upload pictures always prompt not to select pictures, Online no detailed tutorial, do not know my side of the error where, humbly consult
Reply to discussion (solution)
I think it's OK to upload the editor url with the CI upload action.
I think it's OK to upload the editor url with the CI upload action.
Yes, I modified it, but I was prompted not to select files
Here is the code
Content: <textarea name="content" class="xheditor {width:'800',height:'500',upImgUrl:'<?= site_url().'/admin/article/do_upload'?>'}"><?= $content [0][' content ']?></textarea>
Is the editor configuration file configured?
Is the editor configuration file configured?
It's xheditor, I read XH's Official Handbook.
Upload the words to configure upimgurl= ' address I configure is a CI controller inside a method, the method is written in the CI upload class, but in the foreground xheditor edit box after inserting the picture shows you do not select the file prompt, Xheditor official Demo8 Is there is a default upload.php, directly with it can be uploaded successfully, but because the CI framework path problem picture can not display properly, how to write the code inside the controller?
The controller should not only write the display code, but also return to the path of the browse image.
I know how to write the return path to xheditor inside, have you ever used Xheditor, can you help me?
This is the foreground part.
The following is the controller article method Do_upload () {
$config [' upload_path '] = './uploads/';
$config [' allowed_types '] = ' gif|jpg|png|jpeg ';
$config [' max_size '] = ' 100000 ';
$this->load->library (' upload ', $config);
if (! $this->upload->do_upload (' Filedata '))
{
$this->upload->display_errors ();
}
Then you upload the picture in the foreground with the Xheditor edit box, you will be prompted not to select the file! I do not know which problem, Xheditor itself demo with a uplaod.php file, I if upimgurl for it, can upload, but because the CI framework path problem in the XH edit box can not display the picture, this Do_ How do I change the code inside the upload method?
??????????????????????????????????????????
This is the XH default demo inside the upload.php code
/*!
* Upload Demo for PHP
* @requires Xheditor
*
* @author Yanis.wang
* @site http://xheditor.com/
* @licence LGPL (http://www.opensource.org/licenses/lgpl-license.php)
*
* @Version: 0.9.6 (Build 111027)
*
* NOTE 1: This program is only for demonstration purposes, please make sure to modify it according to your own needs, or re-develop
* NOTE 2: This program specifically for HTML5 upload, added special processing
*/
Header (' content-type:text/html; Charset=utf-8 ');
$inputName = ' filedata ';//form file field name
$attachDir = ' upload ';//upload file save path, end not with/
$dirType =1;//1: Deposit by day Directory 2: Monthly deposit Directory 3: By the extension of the directory recommended to use the storage by day
$maxAttachSize =2097152;//max upload size, default is 2M
$UPEXT = ' txt,rar,zip,jpg,jpeg,gif,png,swf,wmv,avi,wma,mp3,mid ';//upload extension
$msgType =2;//return the upload parameter format: 1, return only url,2, return parameter array
$immediate =isset ($_get[' immediate ')? $_get[' immediate ']:0;//immediate upload mode for demonstration purposes only
Ini_set (' Date.timezone ', ' Asia/shanghai ');//Time zone
$err = "";
$msg = "'";
$tempPath = $attachDir. ' /'. Date ("Ymdhis"). Mt_rand (10000,99999). TMP ';
$localName = ";
if (Isset ($_server[' http_content_disposition ')) &&preg_match ('/attachment;\\s+name= ' (. +?) "; \ \s+filename= "(. +?)" /I ', $_server[' http_content_disposition '], $info)) {//HTML5 upload
File_put_contents ($tempPath, file_get_contents ("Php://input"));
$localName =urldecode ($info [2]);
}
else{//standard form-form upload
$upfile =@$_files[$inputName];
if (!isset ($upfile)) $err = ' file field ' name error ';
ElseIf (!empty ($upfile [' Error ')]) {
Switch ($upfile [' Error '])
{
Case ' 1 ':
$err = ' file size exceeds upload_max_filesize value defined by PHP.ini ';
Break
Case ' 2 ':
$err = ' file size exceeds the max_file_size value defined by HTML ';
Break
Case ' 3 ':
$err = ' File upload incomplete ';
Break
Case ' 4 ':
$err = ' no file upload ';
Break
Case ' 6 ':
$err = ' Missing temp folder ';
Break
Case ' 7 ':
$err = ' Write file failed ';
Break
Case ' 8 ':
$err = ' upload is interrupted by another extension ';
Break
Case ' 999 ':
Default
$err = ' No valid error code ';
}
}
ElseIf (Empty ($upfile [' tmp_name ']) | | $upfile [' tmp_name '] = = ' None ') $err = ' no file upload ';
else{
Move_uploaded_file ($upfile [' Tmp_name '], $tempPath);
$localName = $upfile [' name '];
}
}
if ($err = = ") {
$fileInfo =pathinfo ($localName);
$extension = $fileInfo [' extension '];
if (Preg_match ('/^ ('. Str_replace (', ', ' | ', $UPEXT). $/i ', $extension))
{
$bytes =filesize ($tempPath);
if ($bytes > $maxAttachSize) $err = ' Please do not upload size over '. Formatbytes ($maxAttachSize). ' Documents ';
Else
{
Switch ($dirType)
{
Case 1: $attachSubDir = ' Day_ '. Date (' Ymd '); Break
Case 2: $attachSubDir = ' month_ '. Date (' ym '); Break
Case 3: $attachSubDir = ' ext_ '. $extension; Break
}
$attachDir = $attachDir. ' /'. $attachSubDir;
if (!is_dir ($attachDir))
{
@mkdir ($attachDir, 0777);
@fclose (fopen ($attachDir. ' /index.htm ', ' W '));
}
Php_version < ' 4.2.0 ' && Mt_srand ((double) microtime () * 1000000);
$newFilename =date ("Ymdhis"). Mt_rand (1000,9999). '. '. $extension;
$targetPath = $attachDir. ' /'. $newFilename;
Rename ($tempPath, $targetPath);
@chmod ($targetPath, 0755);
$targetPath =jsonstring ($targetPath);
if ($immediate = = ' 1 ') $targetPath = '! '. $targetPath;
if ($msgType ==1) $msg = "' $targetPath '";
else $msg = "{' URL ': '". $targetPath. "', ' localname ': '". jsonstring ($localName). "', ' id ': ' 1 '}"; the//id parameter is fixed for demonstration purposes only. The actual project can be a database ID
}
}
else $err = ' upload file name extension must be: '. $upExt;
@unlink ($tempPath);
}
echo "{' Err ': '". jsonstring ($err). "', ' msg ':". $msg. "}";
function jsonstring ($STR)
{
Return Preg_replace ("/([\\\\\\\\\\/'])/", ' \\\\\\$1 ', $str);
}
function Formatbytes ($bytes) {
if ($bytes >= 1073741824) {
$bytes = Round ($bytes/1073741824 * 100)/100. ' GB ';
} elseif ($bytes >= 1048576) {
$bytes = Round ($bytes/1048576 * 100)/100. ' MB ';
} elseif ($bytes >= 1024) {
$bytes = Round ($bytes/1024 * 100)/100. ' KB ';
} else {
$bytes = $bytes. ' Bytes ';
}
return $bytes;
}
?>
The problem may be that you are using the HTML5 upload method, and the CI upload class does not support
You can use the lower version of IE debugging your program, if you can upload successfully, you need to add the HTML5 upload function in the CI upload class
Method in uplaod.php
If it doesn't work, even if I don't.
The problem may be that you are using the HTML5 upload method, and the CI upload class does not support
You can use the lower version of IE debugging your program, if you can upload successfully, you need to add the HTML5 upload function in the CI upload class
Method in uplaod.php
If it doesn't work, even if I don't.
Xuzuning Thank you for your answer indeed as you said, I put xheditor HTML5 upload closed, the picture can be uploaded normally, but the picture cannot be displayed normally in the edit box, is a fork, is the image upload success after the return path problem, I do not know how to write, Can you please follow my Xheditor demo code simple hints, thanks again
I found a way to see that XH's code has an echo JSON data that's written in its specifications to work perfectly.