100分,求解决将图片以二进制的格式上传到服务器,先生成缩略图放在服务器文件夹
如题,图片先以二进制上传到服务器,利用函数将原图转化为两种不同大小的图片,然后转化为图片放在服务器的paintings/big/和paitings/thumb/下,其路径存入数据库。 现在路径老是出错
未能找到路径“D:\Web\PaintingAccessWeb\Admin\Paintings\Full\63310416867718750070537137.jpg”的一部分。
------解决方案--------------------1。检查路径存在吗?
2。检查有没有写权限
------解决方案--------------------很明显,路径不对.
------解决方案--------------------up
------解决方案--------------------smallImg.aspx:
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "smallImg.aspx.cs " Inherits= "smallImg " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:Button ID= "Button1 " runat= "server " Text= "Button " OnClick= "Button1_Click1 " />
<input id= "File1 " type= "file " runat= "server " />
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox>
<asp:Image ID= "Image2 " runat= "server " Visible= "false " /> <asp:Image ID= "Image1 " runat= "server " Visible= "false " />
</div>
</form>
</body>
</html>
smallImg.aspx.cs:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
public partial class smallImg : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Stream s = File.Open(Server.MapPath( "~/ ")+ "/s_3.gif ", FileMode.Open, FileAccess.Read, FileShare.None);
byte[] b = new byte[(int)s.Length];
s.Read(b, 0, (int)s.Length);
Response.OutputStream.Write(b, 0, (int)s.Length);
s.Close();
}
protected void Button1_Click1(object sender, EventArgs e)
{
if (File1.PostedFile.FileName != null)
{
string namestr = Path.GetFileName(File1.PostedFile.FileName);//提取文件名
File1.PostedFile.SaveAs(Server.MapPath( ". ") + @ "\ " + namestr);
Image2.Visible = true;
Image2.ImageUrl = namestr;
System.Drawing.Image image, aNewImage;
image = System.Drawing.Image.FromStream(File1.PostedFile.InputStream);
decimal width = image.Width;
decimal height = image.Height;
int newwidth, newheight;
if (width > height)
{