上传图片时出现错误
public bool SaveFile(byte[] binData,string fileName){
bool success=false;
string savePath=System.Configuration.ConfigurationSettings.AppSettings["UploadDirectory"];
if(savePath==null) savePath="Photo";
savePath=Server.MapPath(savePath);
if(!savePath.EndsWith("\\")) savePath += "\\";
if(!Directory.Exists(savePath)){
throw new Exception("服务器端没有找到有效的保存路径!");
}
FileStream fileStream=null;
try{
fileStream=new FileStream(savePath + fileName,FileMode.Create,FileAccess.Write);
//write the file
fileStream.Write(binData,0,binData.Length);
fileStream.Flush();//clear the buffer,write the data to the hard disk
success=true;
}catch(Exception ex){
throw new Exception(ex.Message);
}finally{
fileStream.Close();
}
return success;
}
这个是我写的保存图片的代码,但是上传的时候说找不到此路径,为什么啊?
...全文
相关推荐
WordPress在线安装主题、插件及快速发布上传图片时提示错误
正如标题所言主要是因为空间中的C:WINDOWSTEMP目录没有设置IIS访问权限,所以我们只能改变WordPress的上传临时目录,具体修改步骤如下,有类似问题的朋友可以参考下
typora:打字错误上传图片
错别字 打字错误上传图片
Android图片上传,可以选择多张图片,缩放预览,拍照上传等
Android图片上传,可以选择多张图片,缩放预览,拍照上传等
基于bootstrap图片上传_jquery支持多张上传
基于bootstrap图片上传_jquery支持多张上传 基于bootstrap图片上传_jquery支持多张上传
bmob上传图片的小demo
很小的拿来就用, 而且很简单, 避免新手入坑!! 记得有问题给我留言 虽然我也不常来!


