An error occurred while uploading the upload. php file after enabling image upload in the editor ckeditor.

Source: Internet
Author: User
Ask the Editor ckeditor to enable the upload of the upload. php file. After I use the ckeditor to enable the image upload mode, the php source code for image uploading is as follows, but the following error is always prompted during the upload:
Please indicate the cause of the error:




The source code is as follows:
/*
CKEditor_upload.php
Monkee

*/
$ Config = array ();
$ Config ['type'] = array ("flash", "img"); // upload the allowed type value
$ Config ['IMG '] = array ("jpg", "bmp", "gif"); // img allows suffixes
$ Config ['Flash'] = array ("flv", "swf"); // flash allows suffixes
$ Config ['flash _ size'] = 200; // The maximum size of the uploaded flash is KB.
$ Config ['IMG _ size'] = 500; // The maximum size of uploaded img is KB.
$ Config ['message'] = "uploaded successfully"; // The message displayed after the upload is successful. if it is null, the message is not displayed.
$ Config ['name'] = mktime (); // the uploaded file naming rules are named in unix timestamps.
$ Config ['flash _ dir'] = "upload/flash"; // use the absolute address to upload the flash file to facilitate upload. "/" is not added after the php file is placed in any location on the site "/"
$ Config ['IMG _ dir'] = "upload/img"; // The absolute address is used to upload the imgfile. the absolute address is used to facilitate upload. "/" is not added after the php file is placed in any location on the site "/"
$ Config ['site _ url'] = ""; // The website address. this parameter is related to the image upload address. "/" is left blank.
// File Upload
Uploadfile ();
Function uploadfile ()
{
Global $ config;
// Determine whether the call is illegal
If (empty ($ _ GET ['ckeditorfuncnum'])
Mkhtml (1, "", "incorrect function call request ");
$ Fn = $ _ GET ['ckeditorfuncnum'];
If (! In_array ($ _ GET ['type'], $ config ['type'])
Mkhtml (1, "", "incorrect file call request ");
$ Type = $ _ GET ['type'];
If (is_uploaded_file ($ _ FILES ['upload'] ['tmp _ name'])
{
// Determine whether a file is allowed to be uploaded
$ Filearr = pathinfo ($ _ FILES ['upload'] ['name']);
$ Filetype = $ filearr ["extension"];
If (! In_array ($ filetype, $ config [$ type])
Mkhtml ($ fn, "", "incorrect file type! ");
// Determine whether the file size meets the requirements
If ($ _ FILES ['upload'] ['size']> $ config [$ type. "_ size"] * 1024)
Mkhtml ($ fn, "", "the uploaded file cannot exceed". $ config [$ type. "_ size"]. "KB! ");
// $ Filearr = explode (".", $ _ FILES ['upload'] ['name']);
// $ Filetype = $ filearr [count ($ filearr)-1];
$ File_abso = $ config [$ type. "_ dir"]. "/". $ config ['name']. ".". $ filetype;
$ File_host = $ _ SERVER ['document _ root']. $ file_abso;
If (move_uploaded_file ($ _ FILES ['upload'] ['tmp _ name'], $ file_host ))
{
Mkhtml ($ fn, $ config ['site _ url']. $ file_abso, $ config ['message']);
}
Else
{
Mkhtml ($ fn, "", "file Upload failed. Please check the upload directory settings and directory read/write permissions ");
}
}
}
// Output js call
Function mkhtml ($ fn, $ fileurl, $ message)
{
$ Str ='

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.