jquery - How to upload images from its src using generic handler -
i using code upload images using generic handler
<script type="text/javascript"> $(function () { $('#btnupload').click(function () { var fileupload = $("#fileupload1").get(0); var files = fileupload.files; var test = new formdata(); (var = 0; < files.length; i++) { test.append(files[i].name, files[i]); } $.ajax({ url: "uploadhandler.ashx", type: "post", contenttype: false, processdata: false, data: test, // datatype: "json", success: function (result) { alert(result); }, error: function (err) { alert(err.statustext); } }); }); }) </script>
this code works file upload control want upload image sending image src generic handler
like this
var src = 'images/shaiwal.png'; $.ajax({ url: "uploadhandler.ashx", type: "post", contenttype: false, processdata: false, data: src, // datatype: "json", success: function (result) { alert(result); }, error: function (err) { alert(err.statustext); } });
please guys
in code check line:
test.append(files[i].name, files[i]);
instead of using files[i].name
first argument, send other string want, example src.
test.append(src, files[i]);
then in generic handler can create collection of keys first argument used in text.append:
nameobjectcollectionbase.keyscollection keys = context.request.files.keys;
then can access posted file's key using index:
for context.request.files[0]
have keys[0]
in keys collection can src have used in test.append
Comments
Post a Comment