[
https://issues.apache.org/jira/browse/SLING-2499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13287737#comment-13287737
]
Chris Papagrigoriou commented on SLING-2499:
--------------------------------------------
Hey Felix,
thank you for the help. That doesn't seem to solve the issue, besides you only
need to return false, if you want to cancel the submission. Got that from:
http://jquery.malsup.com/form/#options-object
"beforeSubmit
Callback function to be invoked before the form is submitted. The
'beforeSubmit' callback can be provided as a hook for running pre-submit logic
or for validating the form data. If the 'beforeSubmit' callback returns false
then the form will not be submitted. The 'beforeSubmit' callback is invoked
with three arguments: the form data in array format, the jQuery object for the
form, and the Options Object passed into ajaxForm/ajaxSubmit."
> File Upload with Ajax using the .ajaxForm() Method doesnt work properly
> -----------------------------------------------------------------------
>
> Key: SLING-2499
> URL: https://issues.apache.org/jira/browse/SLING-2499
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Environment: Xubuntu Sling 6
> Reporter: Chris Papagrigoriou
> Priority: Critical
>
> The Form:
> <form id="fileUploadForm" action="/content/public/instances" method="POST"
> enctype="multipart/form-data">
> <p><input type="file" name="" id="file" /></p>
> <p><input type="submit" name="upload" id="uploadButton" /></p>
> </form>
> The JavaScript:
> $(document).ready(function() {
> $("#fileUploadForm").ajaxForm({
> delegation : true,
>
> beforeSubmit : function() {
> var fileName = $('#file').val();
> fileName = fileName.replace("C:\\fakepath\\", "");
> $('#file').attr("name", fileName);
> },
>
> success : function() {
> alert("SUCCESS!");
> }
>
> });
>
> });
> It works only, if press the submit button twice. At the first click he
> doesn't create anything. After the second click he uploads the file into
> /content/public/instances/<filename>
> I tested it with a normal form. Seems I get this problem only when I try to
> upload the file with ajax.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira