Coder Social home page Coder Social logo

Comments (6)

m4nuC avatar m4nuC commented on June 1, 2024

You should be able to upload as many files as you wish.

Could you post an example usage of your code ?

from async-busboy.

xinshouke avatar xinshouke commented on June 1, 2024

@m4nuC the below were my codes,so thanks!
--------------------------------------------------ejs html-------------------------------------------------------

form id="fileupload" action="/upload/" method="POST" enctype="multipart/form-data">
input id="uploadedfile" name="uploadedfile" type="file" />
button id='btn4' type="button">start upload /button>

--------------------------------------------------jquery js--------------------------------------------------------
$(function(){$('#btn4').bind("click",function(){
console.log('uploadedfile====>',1);
$.ajaxFileUpload({
url:'/upload',
secureuri:false,
fileElementId:'uploadedfile',
success: function(data,status){
console.log('data====>',data);
console.log('status====>',status);
if(typeof(data.error) != 'undefstatusined'){
if(data.error){
//print error
alert(data.error);
}else{
//clear
// $('#img img').attr('src',url+'cache/'+data.msg);
}
}
},
error: function(data,status,e){
console.log('data====>',data);
console.log('status====>',status);
console.log('e====>',e);
//print error
alert(e);
}
});
})});
----------------------------------------koa2 js in server----------------------------------
if(ctx.url==='/upload'){
const {files, fields} = await asyncBusboy(ctx.req);
console.log('{files, fields}', {files, fields});

from async-busboy.

m4nuC avatar m4nuC commented on June 1, 2024

The problem comes from your upload script that uses the same name for all files. To debug this, open your browser network inspector (4th tab in Chrome inspector) and look at the upload request payload. Does it mountain 2 files? If not you would have to debug your upload script. (likely the fileElementId parameter)

This is not an async-busboy issue.

from async-busboy.

xinshouke avatar xinshouke commented on June 1, 2024

@m4nuC Yes,it's my fault, only text file was unable to log file and filed, such as:
I code as the below:
--------------------------------------code-----------------------------------------
const {files, fields} = await asyncBusboy(ctx.req);
console.log('{files, fields}=====>', {files, fields});
---------------------------the infor from console while uploading txt type file------------------------
{files, fields}=====> { files: [], fields: {} }
---------------------------the infor from console while uploading other documentation--------
{files, fields}=====> { files:
[ ReadStream {
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
path: 'C:\Users\ADMINI~1\AppData\Local\Temp\1463019195662uploadedfile交换中心解决方案.ppt',
fd: 6,
flags: 'r',
mode: 438,
start: undefined,
end: undefined,
autoClose: true,
pos: undefined,
fieldname: 'uploadedfile',
filename: '交换中心解决方案.ppt',
encoding: '7bit',
transferEncoding: '7bit',
mime: 'application/vnd.ms-powerpoint',
mimeType: 'application/vnd.ms-powerpoint' } ],
fields: {} }

Would you please tell me where the cause for? please...

from async-busboy.

m4nuC avatar m4nuC commented on June 1, 2024

This again probably comes from your upload script. Text files should not make any difference. Did you upload them with the same script ?

from async-busboy.

xinshouke avatar xinshouke commented on June 1, 2024

@m4nuC yes, I used the same js file which from internet. I go through every file type, no different was found.
ajaxfileupload.js.txt

from async-busboy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.