1. Upon any type of upload failure, show generic error message and delete all file deployments. NO partial uploads allowed.

 

back to examples

 

All MIME types are being allowed as is an empty field for a file parameter. The code informs the user of any failure; if there is a failure (other than a blank field for a file parameter) then all files are deleted and some generic message is displayed.  This is the simplest solution to implement.

 

 

 

XloadManager xman = new XloadManager(request);

xman.target("file1", "uploaded1", 4096);

xman.target("file2", "uploaded2", 4096);

xman.target("file3", "uploaded3", 4096);

xman.upload();

 

 

//deal with any failed first as if any have failed

//then we delete all files. If we had already dealt

//with any successful uploads then these details would

//incorrectly be in the database.

int fieldBlank = 0;

List failed = xman.getFailedFileUploads();

it = failed.iterator();

while(it.hasMore()){

upload = (XloadFileUpload)it.next();

if(!upload.formFieldBlank()){

xman.deleteAll();

//return a response displaying that there has been

//some kind of failure condition(could list them) and that

//no files have been uploaded.

 

}else{

fieldBlank++;

}

}

if(fieldBlank == 3){

//return a response displaying that there have been

//no files uploaded as all file fields are blank.

}else{

//handle successful uploads

List successful = xman.getSuccessfulFileUploads();

XloadFileUpload upload = null;

Iterator it = successful.iterator();

while(it.hasMore()){

upload = (XloadFileUpload)it.next();

XloadFile file = upload.getFile(1);

//place file details inside relational database

}

 

//return a response displaying successful upload of file(s).

}

 

 

 

back to examples

 

 

 

© Gubutech(Xload) 2006  (v1.2)