Ewebeditor Editor upload picture Path error resolution [incurable diseases] "go, author: UNVs"

Source: Internet
Author: User

Do a multi-version of the site, backstage with the editor is ewebeditor,net version, after the discovery of uploading pictures or files, the path error can not be displayed, you must manually modify the line.

In order to more clearly explain the problem, I will say in more detail, the first is the Web site file framework path (multi-version site for instance), and then explain the file meaning of the upload file, and finally according to the problem to say the different reasons and solutions:

I. Web document Framework

Wootroot (Web root directory) CN (Chinese Version folder) Admin (Background directory) Ewebeditor (Background Editor folder) Upload (upload processing folder) Default.aspx
En (English folder) Admin (Background directory) Dialog (Editor call page folder) Img.htm
Uploadimg (upload picture Save folder) Webconfig (config file in each version directory)
Webconfig (root directory configuration file)

The above column frame diagram, should be easier to understand, O (∩_∩) O, meaning that a column is the site's first-level directory

Ii. interpretation of the meaning of the document

Upload the file, save the file, and return the value, Mainly in the editor directory in the upload folder in the Default.aspx, so below, only explain this page (in order to let Bo friends more understand, also click on the editor to call the file, that is the framework of the dialog folder in the Img.htm file), the following is the Ewebeditor editor Interface diagram:

1, click on the editor of the picture editing, pop up the following dialog box,

2, the following upload folder in the main code default.aspx.cs (ie click the above icon to confirm the button, triggered by the event code):

protected void Button1_Click (object sender, EventArgs e)
{
if (This.uploadfile.PostedFile.FileName = = "")//Determine whether the file is empty, popup corresponding promotion;
{
Response.Write ("<script>parent.document.all (' divprocessing '). style.display= ' None ';</script>");
}
Else
{
String _flag = request["Flag"]; determine file upload type;
String _regex = "";

Switch (_flag)
{
Case "IMG":
_regex = @ "^.+\. (jpe?g|gif|bmp|png) $ ";
In
; Break
Case "Flash":
_regex = @ "^.+\. (SWF) $ ";
Break
Case "Media":
_regex = @ "^.+\. (Wmv|avi|rmvb|mpeg|mov) $ ";
Break
Case "File":
_regex = @ "^.+\. (rar|zip|doc|pdf|txt) $ ";
Break
Default
_regex = @ "^.+\. (jpe?g|gif|swf|wmv|avi|rmvb|mpeg|mov|rar|zip|doc|pdf|txt) $ ";
Break
}//This paragraph does not introduce, determine the file type and format;

Regex test = new Regex (_regex);//Invoke event;

if (test. IsMatch (UploadFile. Postedfile.filename) = = True)
{
ClientScriptManager cs = Page.clientscript;

String imagesfolder = configurationmanager.appsettings["Uploadfolder"]. ToString (); Tune the configuration file path;
string filename = UploadFile (UploadFile, Imagesfolder); Call the UploadFile method to get the file path, where UploadFile is the name of the control that uploads the file;
String apurl = Request.Url.ToString (); Gets the current URL path;
string apurl2 = Request.currentexecutionfilepath; Get the file directory name; for example:/cn/admin/ewebeditor/upload/default.aspx– details please see request return to current address Daquan
String tempurl = Apurl. Substring (0, Apurl. IndexOf (APURL2)); The path to intercept the specified number of bits;
string appurl = Request.applicationpath; Invoke the application path; for example: www.unvs.cn
String hurl = AppUrl + filename. Replace ("~/", "" "); This step is the most critical, directly affect whether you can upload a successful, meaning the directory path + file is replaced by the path (because the configuration file fetch path contains ~/, if not replaced, will be error); Hurl the parameters returned after the picture is saved, that is, the image src;

if (AppUrl. length = = 1)//This sentence to judge the comment code is to determine the length of AppUrl acquisition, and the parameters are assigned;
Hurl = AppUrl + filename. Replace ("~/", "" ");
Else
Hurl = AppUrl + "/" + filename. Replace ("~/", "" ");

String Imgpreview = Tempurl + hurl; Preview link;

                cs. RegisterClientScriptBlock (this. GetType (), "tt", "Parent.document.all (' divprocessing '). style.display= ' None ';p arent.document.all (' Imgpreview '). Src= ' + Imgpreview + ';p arent.document.all (' Hurl '). Value= ' "+ Hurl +" ';p arent.document.all (' D_fromurl '). value= ";", true);  //return parameter;

Lblinfo. Text = "File Upload succeeded!" <a href=\ "\" > Re-upload </a> ";
}
Else
{
Lblinfo. Text = "The file type you uploaded is not correct!" <a href=\ "\" > Re-upload </a><script>parent.document.all (' divprocessing '). style.display= ' None '; </ Script> ";
}
}
}

3, the following is the CN version of the Webconfig configuration file, the key part:

<appSettings>
<add key= "Cndbpath" value= "~/cn/app_data/##@@##.mdb"/>//Here are the first few configuration is the path, directly from the background to adjust;
<add key= "Upimgpath" value= "~/uploadimg/"/>
<add key= "Upfilepath" value= "~/uploadimg/"/>
<add key= "Upsmallimgpath" value= "~/uploadimg/"/>
<add key= "Uploadfolder" value= "~/uploadimg/"/>
<add key= "uploadexts" value= "Jpg|gif|bmp"/>
<add key= "smallimgheight" value= "/>"
<add key= "smallimgwidth" value= "/>"
<add key= "DefaultLanguage" value= "Kn"/>
<add key= "DISABLECN" value= "true"/>
<add key= "Disableen" value= "true"/>
<add key= "Disablejn" value= "true"/>
<add key=
"Disablekn" value= "false"/>
<add key= "virtualpath" value= ""/>
</appSettings>

4, simple analysis of various image upload path Error resolution method:

A picture path is: http://www.***.cn/~/uploadimg/pic.jpg

This error is caused by the hurl parameter, without replacing the ~/symbol with "", and adding the hurl parameter directly to filename. Replace ("~/", "");

A picture path is: http://uploadimg/pic.jpg

This error is also in the hurl parameter, the substitution error, did not add "/" in the resulting, the wrong way of writing is the filename. Replace ("~", ""), plus/can, temporarily do not know why/no replacement, will appear above the path, the site URL will disappear, May//two slash will be the site URL hidden;

5, the above is the time to upload the image path to return the wrong solution, only the individual analysis of this, I do not know whether the explanation is correct or wrong, but also hope that the same fellow people pointed out and left their own insight!! O (∩_∩) o

Ewebeditor Editor upload picture path error resolution [troubleshooting] "Go, UNVs"

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.