Ewebeditor File Upload Problems

Source: Internet
Author: User

When users have special requirements, Program Members have to study the ewebeditor's Code , Which is quite troublesome. I have gone through this process and finally met the customer's requirement: A link is made after some texts on the webpage, and an image or a detailed introduction or a video is displayed after the user clicks. Considering that only some text is displayed on the webpage, I have set this function: When uploading, the file name should be the text to be displayed, during the upload, we can intercept the text (remove the file type ). When the Administrator deletes the files uploaded by ewebeditor, the Administrator must extract the file paths and save them to the database. Multiple files may be uploaded each time, we must read the paths of multiple files and store them in a field in the database table. Therefore, I write the paths to $ _ Session, then, process the file path on another page.
1. Grant the uploadfile permission so that the folder can be written and read.
2. Include/upload. php Copy code The Code is as follows: // Save the operation
Function dosave ()
{
Global $ scontentpath, $ ssavefilename, $ soriginalfilename;
Doupload ();
$ Spathfilename = $ scontentpath. $ ssavefilename;
$ Pathnum = count ($ _ session ["ewebpath"]);
$ _ Session ["ewebpath"] ["$ pathnum"] = $ spathfilename;
// Obtain the path of the File Uploaded By eweb, write the path of each uploaded file to the session, and write the path obtained on the other page to the database.
/* $ Path = array ();
$ Pathnum = count ($ _ session ["ewebpath"]);
For ($ I = 0; $ I <$ pathnum; $ I ++)
{
$ Path [$ I] = $ _ session ["ewebpath"] [$ I];
$ Path [$ I] = substr ($ path [$ I], 8); // handle the path according to the actual situation.
}
$ Path = implode ('|', $ PATH );
Session_unregister ("ewebpath ");*/
Outscript ("parent. uploadsaved ('$ spathfilename'); var OBJ = parent. dialogarguments. dialogarguments; If (! OBJ) OBJ = parent. dialogarguments; try {obj. adduploadfile ('$ soriginalfilename', '$ ssavefilename', '$ spathfilename');} catch (e ){}");
}

3. Modify the formats of uploaded files supported by ewebeditor in startup. php.
4. Dialog/file.htmCopy codeThe Code is as follows: // get the file name to the hidden input box.
Function getfilename (URL, OPT)
{
D_filename.value = URL. substr (URL. lastindexof (OPT) + 1 );
// Retrieve the file name without a suffix (for example, "signal and system. Doc" will get "signal and system ")
S1 = d_filename.value.split ("."); // splits the string.
D_filename.value = S1 [0];
}

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.