c# - Upload a file upon an asmx web service -
i have problem while uploading file via asmx webservice.
here html code :
<form method="post" action="/_wscommunity_/publiccommunity.asmx/uploadtemppicture" encoding="multipart/form-data" enctype="multipart/form-data" id="form_upload" target="upload_target"> <input type="file" name="file[]" id="file_upload"> <input type="submit" name="action" value="upload"> <iframe name="upload_target" id="upload_target"> </iframe> </form>
on javascript file on onchange event :
$("form_upload").target = 'upload_target'; $("form_upload").submit();
when form submit receive in post :
parts multipart/form-data
file[] gif89a �÷�������3��f����Ì��ÿ�+��+3�+f�+�+Ì�+ÿ�u��u3�uf�u�uÌ�uÿ���3�f��Ì�ÿ�ª��ª3�ªf�ª�ªÌ�ªÿ�Õ��Õ3�Õf�Õ�ÕÌ�Õÿ�ÿ��ÿ3�ÿf�ÿ�ÿÌ�ÿÿ3��3�33�f3�3�Ì3�ÿ3+�3+33+f3+3+Ì3+ÿ3u�3u33uf3u3uÌ3uÿ3�333f33Ì3ÿ3ª�3ª33ªf3ª3ªÌ3ªÿ3Õ�3Õ33Õf3Õ3ÕÌ3Õÿ3ÿ�3ÿ33ÿf3ÿ3ÿÌ3ÿÿf��f�3f�ff�f�Ìf�ÿf+�f+3f+ff+f+Ìf+ÿfu�fu3fuffufuÌfuÿf�f3ffffÌfÿfª�fª3fªffªfªÌfªÿfÕ�fÕ3fÕffÕfÕÌfÕÿfÿ�fÿ3fÿffÿfÿÌfÿÿ���3�f��Ì�ÿ+�+3+f++Ì+ÿu�u3ufuuÌuÿ�3fÌÿª�ª3ªfªªÌªÿÕ�Õ3ÕfÕÕÌÕÿÿ�ÿ3ÿfÿÿÌÿÿÌ��Ì�3Ì�fÌ�Ì�ÌÌ�ÿÌ+�Ì+3Ì+fÌ+Ì+ÌÌ+ÿÌu�Ìu3ÌufÌuÌuÌÌuÿÌ�Ì3ÌfÌÌÌÌÿ̪�̪3̪f̪̪Ì̪ÿÌÕ�ÌÕ3ÌÕfÌÕÌÕÌÌÕÿÌÿ�Ìÿ3ÌÿfÌÿÌÿÌÌÿÿÿ��ÿ�3ÿ�fÿ�ÿ�Ìÿ�ÿÿ+�ÿ+3ÿ+fÿ+ÿ+Ìÿ+ÿÿu�ÿu3ÿufÿuÿuÌÿuÿÿ�ÿ3ÿfÿÿÌÿÿÿª�ÿª3ÿªfÿªÿªÌÿªÿÿÕ�ÿÕ3ÿÕfÿÕÿÕÌÿÕÿÿÿ�ÿÿ3ÿÿfÿÿÿÿÌÿÿÿ������������!ù��ü�,���� ����÷ h° a�*\È0 �;
source -----------------------------292403007321689
content-disposition: form-data; name="file[]"; filename="untitled.gif" content-type: image/gif
gif89a �÷�������3��f����Ì��ÿ�+��+3�+f�+�+Ì�+ÿ�u��u3�uf�u�uÌ�uÿ���3�f��Ì�ÿ�ª��ª3�ªf�ª�ªÌ�ªÿ�Õ��Õ3�Õf�Õ�ÕÌ�Õÿ�ÿ��ÿ3�ÿf�ÿ�ÿÌ�ÿÿ3��3�33�f3�3�Ì3�ÿ3+�3+33+f3+3+Ì3+ÿ3u�3u33uf3u3uÌ3uÿ3�333f33Ì3ÿ3ª�3ª33ªf3ª3ªÌ3ªÿ3Õ�3Õ33Õf3Õ3ÕÌ3Õÿ3ÿ�3ÿ33ÿf3ÿ3ÿÌ3ÿÿf��f�3f�ff�f�Ìf�ÿf+�f+3f+ff+f+Ìf+ÿfu�fu3fuffufuÌfuÿf�f3ffffÌfÿfª�fª3fªffªfªÌfªÿfÕ�fÕ3fÕffÕfÕÌfÕÿfÿ�fÿ3fÿffÿfÿÌfÿÿ���3�f��Ì�ÿ+�+3+f++Ì+ÿu�u3ufuuÌuÿ�3fÌÿª�ª3ªfªªÌªÿÕ�Õ3ÕfÕÕÌÕÿÿ�ÿ3ÿfÿÿÌÿÿÌ��Ì�3Ì�fÌ�Ì�ÌÌ�ÿÌ+�Ì+3Ì+fÌ+Ì+ÌÌ+ÿÌu�Ìu3ÌufÌuÌuÌÌuÿÌ�Ì3ÌfÌÌÌÌÿ̪�̪3̪f̪̪Ì̪ÿÌÕ�ÌÕ3ÌÕfÌÕÌÕÌÌÕÿÌÿ�Ìÿ3ÌÿfÌÿÌÿÌÌÿÿÿ��ÿ�3ÿ�fÿ�ÿ�Ìÿ�ÿÿ+�ÿ+3ÿ+fÿ+ÿ+Ìÿ+ÿÿu�ÿu3ÿufÿuÿuÌÿuÿÿ�ÿ3ÿfÿÿÌÿÿÿª�ÿª3ÿªfÿªÿªÌÿªÿÿÕ�ÿÕ3ÿÕfÿÕÿÕÌÿÕÿÿÿ�ÿÿ3ÿÿfÿÿÿÿÌÿÿÿ������������!ù��ü�,���� ����÷ h° a�*\È0 �; -----------------------------292403007321689--
and in asmx webservice :
[webmethod] public ajaxresponse uploadtemppicture() { ajaxresponse response = new ajaxresponse(); httpfilecollection myfilecollection; httppostedfile myfile; myfilecollection = httpcontext.current.request.files; myfile = myfilecollection[0]; .... }
the web service call receive error :
system.web.services.protocols.soapexception: system.web.services.protocols.soapexception: server unable process request. ---> system.exception: problem uploading file: index out of range. must non-negative , less size of collection. parameter name: index
Comments
Post a Comment