input type=file...

input type=file...

LapointeLapointe Posts: 430Questions: 81Answers: 4

Hello

I need to set an editor form to replace this one

<form method='post' action='import.php?Fo=".$OperationID."' enctype='multipart/form-data'>     
    <input type='file' name='".$fName."' accept='.txt,.csv'>    
    <input type='hidden' name='MAX_FILE_SIZE' value='2097152'>     
    <input type='button' value='Annuler' onClick='window.close()'>
    <input type='submit' value='Envoyer'>    
</form>

Using the 'upload' type the file load occurs after file selection... and I don't want it to load before user click on submit button...
I just want just to get the filename, display it and after user click on submit button, do check content manually (not after select the file)...
Is there a way to get this running (perhaps just an upload file option) ?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,195Questions: 1Answers: 10,412 Site admin

    Unfortunately not at the moment. The file upload input type is always async in Editor at this time. Providing a synchronous option is something we will look into in future.

    Allan

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    Thanks Allan
    So is there a way to simulate a file input and keep the same aspect as the rest of application (using render or other) ?

  • allanallan Posts: 63,195Questions: 1Answers: 10,412 Site admin
    edited October 2019

    The only way to do it would be to create a field type plug-in that would read the file locally and then return the file's value (perhaps as a base64 string) as part of the form. That would work just fine, but I don't have such a plug-in available I'm afraid.

    Allan

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    Hello Allan
    In fact I just need to get the file name, not the file content...

  • allanallan Posts: 63,195Questions: 1Answers: 10,412 Site admin

    So you don't use the content from the file at all? I suppose you could use preUpload to get information about the file and then write it into the value of a different field, but the upload field wasn't designed with that in mind.

    I'd actually suggest writing a custom upload field plug-in if all you want is the file name (although I'm not clear on why you wouldn't want the content as well).

    Allan

  • allanallan Posts: 63,195Questions: 1Answers: 10,412 Site admin
    Answer ✓

    Oh - I think I get it having thought about it a little more. What you mean is that you want the file name to be shown and then the file be submitted when the form is - is that correct?

    If so, then my previous answer applies. You'd need a custom field plug-in to do that. What you are looking for (file upload inline with the rest of the form) is not something that Editor currently does as I mentioned above.

    Allan

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    Hello Allan

    Sorry to late response
    Yes I just want to get the filename, nor get content at this time. This is an csv import file openened in an import module that check a lot of cases before accept import, so with fileupload the import module is directly fired, what I don't want to...
    I'm sure a simple getfilename (as windows interface do in commondialog.dll) shoul be usefull for a solution.
    Thanks for time lost for me

    So you don't use the content from the file at all? I suppose you could use preUpload to get information about the file and then write it into the value of a different field, but the upload field wasn't designed with that in mind.
    
    I'd actually suggest writing a custom upload field plug-in if all you want is the file name (although I'm not clear on why you wouldn't want the content as well).
    
    Allan
    
This discussion has been closed.