Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

ScriptData and Java-Servlets
  • Hello from my little Java world again! xD

    My problem today is that I want to pass a specific file name because I need to identify the files uploaded. I know this is done by scriptData, something like this if I'm not confused:

    $('#fileInput').fileUploadSettings('scriptData', '&newFileName=${bean.newFileName}');


    (Note: i write this when i was using PHP)

    EDIT: I try it without the & and continue without working.

    But i have no idea how to retrive it when in the server. when I parseRequest i get the file, and 2 formFields that contains the file name(not the changed one) and another one that don't helps me either...

    List fileItems = fu.parseRequest(req);


    Someone knows how to do this?

    Here is my servlet if it helps, or if any other user is searching something similar:

    public boolean procesaFicheros(HttpServletRequest req, PrintWriter out, MrBean bean) {
    try {
    if (!ServletFileUpload.isMultipartContent(req)) {
    return false;
    }
    DiskFileUpload fu = new DiskFileUpload();

    fu.setSizeMax(1000 * 1024 * 512); // 512 K
    fu.setSizeThreshold(4096);

    fu.setRepositoryPath(\"C:\\temp\\\");

    List fileItems = fu.parseRequest(req);//Here I get the list of items

    if (fileItems == null) {
    return false;
    }

    Iterator i = fileItems.iterator();
    FileItem actual = null;

    File fichero = null;
    while (i.hasNext()) {

    actual = (FileItem) i.next();
    if (!actual.isFormField()) {
    String fileName = actual.getName();//This name is the \"normal\" one, without any change

    fichero = new File(fileName);

    fichero = new File(\"C:\\temp\\\" + fichero.getName());

    } else {
    String fieldName= actual.getFieldName();Here i get a \"Filename\" that i don't have any input in my form with that name... is of Uploadify??
    String fieldValue= actual.getString();//Here i get the file name too, but without any change either
    }
    }

    if (fichero != null) {
    actual.write(fichero);
    } else {
    return false;
    }

    } catch (Exception e) {
    return false;
    }

    return true;
    }
  • Nobody knows how to pass scriptData in Java?? I'm getting mad!! :(
  • YEP! I get it... :mrgreen:

    if you always do something one way and works, why change it just because the outside is diferent?? Inside continue beeing the same! I just need to see it...

    Thanks anyways, and I post this if someone else ever have the same problem.

    Solutions, pass the parameters as a normal request:

    'script'     : 'servlet?id=${bean.idFecha}',


    Uploadify rocks!

    Nicte
  • can you upload multiples files with java-servlets?? i dont know , how can you help me?? please.