我有一個html上傳<input type="file" id="myfile"/>
。當我點擊它,它正在加載文件,但不能像firefox3中獲得像c:documents/images...
等整個路徑。使用jquery保存asp.net中的html文件上傳文件
我也有一個HTML按鈕點擊我必須保存文件到我的應用程序的根文件夾使用JSON保存圖像時,然後彈出應該打開瀏覽圖像,允許用戶裁剪圖像使用jcrop。當用戶完成剪裁時,應該使用jquery和json並僅使用html控件將圖像保存回根文件夾(服務器端)。
所有的東西都應該用jquery和json以及使用webmethods的代碼來處理。
這裏是我的代碼:
<input type="file" class="select-file" id="file_attach" />
enter code here
$('#btnNextPhoto').click(function() {
//Cancel the link behavior
filename = $('#file_attach').val();
//e.preventDefault();
if (filename != "") {
alert("i am svaing");
SaveUncroppedImage();
}
}
function SubmitUncroppedImage(image) {
var ticket = getCookieFromPage();
var DTO = JSON.stringify({ image: image, encryptedTicket: ticket });
$.ajax({
type: "POST",
url: "../Members/EditProfile.aspx/SaveUncroppedImage",
data: DTO,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg.d);
$("#cropbox").attr('src', msg.d).show();
$('#container').hide();
},
error: function (msg) {
alert(msg.d);
}
});
}
[System.Web.Services.WebMethod]
public static string SaveUncroppedImage(string image, string encryptedTicket)
{
ImageFunctions img = new ImageFunctions();
string guid = Guid.NewGuid().ToString();
string fileName = guid + ".jpg";
//string rPath = "/images/flower.jpg";
string root = "C:\\Sites\\images\\videothumbs";
file_attach.SaveAs(root + image);"
請提高您的問題在未來的質量。 –
請現在檢查我的代碼 – Tan
我試過(最好)對您的問題進行其他編輯。你能否請他們檢查正確性,做出任何改變並讓我知道?請注意,我的大部分編輯只是爲您的問題添加段落(這是一段厚實的文字牆),適當的大寫字母和一些標點符號。讓我知道這是否足以描述你的問題,我會重新打開它。 –