not enough input arguments
1 回表示 (過去 30 日間)
古いコメントを表示
function subdata=multipart2struct(subrequestdata,config)
request_text=char(subrequestdata);
request_lines = regexp(request_text, '\n+', 'split');
request_words = regexp(request_lines, '\s+', 'split');
i=1;
subdata=struct;
subdata.Name='';
subdata.Filename='';
subdata.ContentType='';
subdata.ContentData='';
while(true)
i=i+1; if((i>length(request_lines))||(uint8(request_lines{i}(1)==13))), break; end
line=request_lines{i};
type=request_words{i}{1};
switch(type)
case 'Content-Disposition:'
for j=3:length(request_words{i})
line_words=regexp(request_words{i}{j}, '"', 'split');
switch(line_words{1})
case 'name='
subdata.Name=line_words{2};
case 'filename='
subdata.Filename=line_words{2};
end
end
case 'Content-Type:'
subdata.ContentType=rmvp(line(15:end));
end
end
w=find(subrequestdata==10);
switch(subdata.ContentType)
case ''
subdata.ContentData=char(subrequestdata(w(i)+1:end));
otherwise
subdata.ContentData=subrequestdata(w(i)+1:end);
[pathstr,name,ext] = fileparts(subdata.Filename);
filename=['/' char(round(rand(1,32)*9)+48)];
fullfilename=[config.temp_folder filename ext];
fid = fopen(fullfilename,'w'); fwrite(fid,subdata.ContentData,'int8'); fclose(fid);
subdata.Filename=fullfilename;
end
0 件のコメント
採用された回答
Explorer
2016 年 2 月 23 日
編集済み: Explorer
2016 年 2 月 23 日
The code you have provided above is of function which need two arguments (values).
1. Copy the above code, paste it in new script file and save it with this name " multipart2struct.m"
2. Enter values of "subrequestdata" and "config" in command window as follows:
subrequestdata =
config =
3. Call your function in Command window after enter values of "subrequestdata" and "config"
multipart2struct(subrequestdata,config)
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Programming Utilities についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!