You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Carsten Ziegeler (Jira)" <ji...@apache.org> on 2023/04/13 05:08:00 UTC

[jira] [Resolved] (SLING-2499) File Upload with Ajax using the .ajaxForm() Method doesnt work properly

     [ https://issues.apache.org/jira/browse/SLING-2499?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler resolved SLING-2499.
-------------------------------------
    Resolution: Won't Fix

> 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: Minor
>
> 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 was sent by Atlassian Jira
(v8.20.10#820010)