editor编辑器本地插入图片一切正常,但是发布后在服务器上就不能插入图片
这是editor的upload源代码
using System;
using System.Collections;
using System.Web;
using System.IO;
using System.Globalization;
using LitJson;public partial class Manage_editor_net_upload : System.Web.UI.Page
{
//文件保存目录路径
private String savePath = "../attached/images/";
//文件保存目录URL
private String saveUrl = "../editor/attached/images/";
//定义允许上传的文件扩展名
private String fileTypes = "gif,jpg,jpeg,png,bmp";
//最大文件大小
private int maxSize = 1000000; protected void Page_Load(object sender, EventArgs e)
{
HttpPostedFile imgFile = Request.Files["imgFile"];
if (imgFile == null)
{
showError("请选择文件。");
} String dirPath = Server.MapPath(savePath);
if (!Directory.Exists(dirPath))
{
showError("上传目录不存在。");
} String fileName = imgFile.FileName;
String fileExt = Path.GetExtension(fileName).ToLower();
ArrayList fileTypeList = ArrayList.Adapter(fileTypes.Split(',')); if (imgFile.InputStream == null || imgFile.InputStream.Length > maxSize)
{
showError("上传文件大小超过限制。");
} if (String.IsNullOrEmpty(fileExt) || Array.IndexOf(fileTypes.Split(','), fileExt.Substring(1).ToLower()) == -1)
{
showError("上传文件扩展名是不允许的扩展名。");
} String newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt;
String filePath = dirPath + newFileName; imgFile.SaveAs(filePath); String fileUrl = saveUrl + newFileName; Hashtable hash = new Hashtable();
hash["error"] = 0;
hash["url"] = fileUrl;
Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
Response.Write(JsonMapper.ToJson(hash));
Response.End();
} private void showError(string message)
{
Hashtable hash = new Hashtable();
hash["error"] = 1;
hash["message"] = message;
Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
Response.Write(JsonMapper.ToJson(hash));
Response.End();
}
}文件路径都没问题
这是editor的upload源代码
using System;
using System.Collections;
using System.Web;
using System.IO;
using System.Globalization;
using LitJson;public partial class Manage_editor_net_upload : System.Web.UI.Page
{
//文件保存目录路径
private String savePath = "../attached/images/";
//文件保存目录URL
private String saveUrl = "../editor/attached/images/";
//定义允许上传的文件扩展名
private String fileTypes = "gif,jpg,jpeg,png,bmp";
//最大文件大小
private int maxSize = 1000000; protected void Page_Load(object sender, EventArgs e)
{
HttpPostedFile imgFile = Request.Files["imgFile"];
if (imgFile == null)
{
showError("请选择文件。");
} String dirPath = Server.MapPath(savePath);
if (!Directory.Exists(dirPath))
{
showError("上传目录不存在。");
} String fileName = imgFile.FileName;
String fileExt = Path.GetExtension(fileName).ToLower();
ArrayList fileTypeList = ArrayList.Adapter(fileTypes.Split(',')); if (imgFile.InputStream == null || imgFile.InputStream.Length > maxSize)
{
showError("上传文件大小超过限制。");
} if (String.IsNullOrEmpty(fileExt) || Array.IndexOf(fileTypes.Split(','), fileExt.Substring(1).ToLower()) == -1)
{
showError("上传文件扩展名是不允许的扩展名。");
} String newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt;
String filePath = dirPath + newFileName; imgFile.SaveAs(filePath); String fileUrl = saveUrl + newFileName; Hashtable hash = new Hashtable();
hash["error"] = 0;
hash["url"] = fileUrl;
Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
Response.Write(JsonMapper.ToJson(hash));
Response.End();
} private void showError(string message)
{
Hashtable hash = new Hashtable();
hash["error"] = 1;
hash["message"] = message;
Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
Response.Write(JsonMapper.ToJson(hash));
Response.End();
}
}文件路径都没问题
解决方案 »
- CompareTo方法
- C# Winform 操作 Excel 必须要拷贝Microsoft.Office.Interop.Excel.dll么
- 怎么用代码实现六边形图像??如下图
- c# 如何引用PB的DLL文件
- 如何将c++的struct表示为C#,并把 bytes? Marshal的方式仅支持简单类型,不支持char A[20]的形式。
- GetFullPath 为什么会出错?谁能帮帮忙,先谢了。
- 客户端一开机,服务器就能获得他的mac地址,请问用.net怎么写
- ACCESS的SQL执行报错,语法错误,怎么可能是错误的呢??
- DataGridView格式化日期输入问题
- 初学unity3D,C#脚本,求朋友们帮帮忙解决下这个错误
- GridView中的模板列中是否能嵌套一个GridView
- 有关属性的问题(有代码)
应该不是 FCK 、 FCK 没有那么啰嗦、
那你看看服务器上是否已经有图片了,如果有图片了看看你的程序提取的路径是否正确如果服务器没有图片,而且你的IIS服务器也允许上传,检查编辑器的上传代码和上传路径