我想通过网络应用程序访问iphone相机并拍照并将其保存到我的电脑。 我可以访问相机,但无法将图片从iphone保存到计算机。
<form action="upload.aspx" method="post" enctype="multipart/form-data">
<input type="file" id="files" runat="server" name="files"
accept="image/*" capture="camera" />
</form>
upload.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace PartsMobile
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Files["files"] != null)
{
HttpPostedFile MyFile = Request.Files["files"];
//Setting location to upload files
//string TargetLocation = Server.MapPath("~/Files");
string TargetLocation =
@"c:\Projects3\Files";
try
{
if (MyFile.ContentLength > 0)
{
//Determining file name
string FileName = MyFile.FileName;
string str = Path.GetFileName(FileName);
//Determining file size
int FileSize = MyFile.ContentLength;
//Creating a byte array corresponding to file size.
byte[] FileByteArray = new byte[FileSize];
//Posted file is being pushed into byte array.
MyFile.InputStream.Read(FileByteArray, 0, FileSize);
//Uploading properly formatted file to server.
MyFile.SaveAs(Path.Combine(TargetLocation, str));
var invalidChars = Path.GetInvalidFileNameChars();
}
}
catch (Exception BlueScreen)
{
//Handle errors
}
}
}
}
}
答案 0 :(得分:0)
我终于解决了它。这是权限问题。我将app pool a / c添加到文件夹,这解决了问题。谢谢你的帮助