function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sohan RajSohan Raj 

dropzone image upload issue

Hello,

I am using Dropzone for upload file drag and drop. But when I submit form then it gives error required BODY is missing. Without dropzone its working correct.

I am using below code:
 
<apex:form id="dropzoneForm" styleClass="dropzone1">
                                                                                <div class="fallback">
                                                                                    <apex:inputFile id="profilePhoto" value="{!profilePhoto}" />
                                                                                </div>
                                                                                <br />
                                                                                <br />
                                                                                <apex:commandButton action="{!saveProfilePhoto}" title="Save Changes" value="Save Changes" styleClass="btn btn-primary btn-sm btn-block btnsave" id="btnsave"/>
                                                                            </apex:form>



 
<script>
Dropzone.options.dropzoneForm = {
            paramName: "file", // The name that will be used to transfer the file
            maxFilesize: 2, // MB
            dictDefaultMessage: "<strong>Drop files here or click to upload. </strong>"
                };
</script>

Apex Code:
 
public PageReference saveProfilePhoto()
    {
        try{
        //system.debug('testpic');
            Attachment profilePhotoObj = new Attachment();
            profilePhotoObj.body = profilePhoto;
            profilePhotoObj.name='profilephoto';
            profilePhotoObj.ParentId = artist.id;
            insert profilePhotoObj;
            
            
            String attachedPhotoId = profilePhotoObj.id;
            String profilePhotoObjId = attachedPhotoId.subString(0,15);
            
            artist.Artist_Photo__c  = '/servlet/servlet.FileDownload?file='+profilePhotoObjId ;
            
            upsert artist;
            
            artistId = ApexPages.currentPage().getParameters().get('artistId');
            //system.debug('artist id ='+artistId );
            PageReference pg = new PageReference('/apex/Profile?artistid='+artistId );
            pg.setRedirect(true);
            return pg;
        }
        catch(Exception ex)
        {
            ApexPages.addMessages(ex);
            system.debug('testpic'+ex);
        }
        
        return null;
    }



Can anyone please provide code for this using dropzone.

Thanks
Sohan Raj Gupta
Pandeiswari SathiakumarPandeiswari Sathiakumar
Hi.. 

Will you able to fix the issue.. I have same requirment to work on it now