Editor File Upload

Editor File Upload

OrayiOrayi Posts: 6Questions: 1Answers: 0

I have managed to get the file upload to upload the temporary file but I seem to be having issues after that.

When the form is submitted it's not post any data.

This only happens in forms with a file upload control, if there isn't one it works fine.

Any ideas what I might be doing wrong?

This question has an accepted answers - jump to answer

Answers

  • OrayiOrayi Posts: 6Questions: 1Answers: 0

    Might be a Laravel issue.

    Seems to work fine if I use different functions for upload and submit.

  • OrayiOrayi Posts: 6Questions: 1Answers: 0

    On a side note, I've noticed that the files array doesn't get posted with the form unless I do the following:

    "ajax": {
                    url: "/cms/pr/ajax-pr-file-editor",
                    headers: {
                        'X-CSRF-Token': $('[name=_token]').val()
                    },
                    data: function ( d ) {
                        d.files = tablePrFiles.files();
                    }
                }
    
  • allanallan Posts: 63,353Questions: 1Answers: 10,444 Site admin

    What code are you using for the file upload? I'm not particularly familiar with Laravel, so I'm not sure how much help I will be able to offer there.

    Allan

  • OrayiOrayi Posts: 6Questions: 1Answers: 0

    A function within my controller that uploads the file to a temporary folder.

    It's all working fine now. I don't think laravel likes posting to the same function twice.

    Should files be automatically appended to the post data?

  • allanallan Posts: 63,353Questions: 1Answers: 10,444 Site admin

    Should files be automatically appended to the post data?

    At what point? When the file is selected it should be uploaded at that point as part of a multi-part upload.

    Allan

  • OrayiOrayi Posts: 6Questions: 1Answers: 0

    Guess I'm doing it a bit different to expected.

    • File uploaded to a temporary location using a unique name (time().extention), no record is created at this point
    • Form submitted with the other data to create the record
    • Once the record has been created the temporary file is then moved to the proper location and renamed to the original upload name

    Due to foreign key constraints and required data I can't create the record when the file is uploaded.

    What I have done is all working it would just be handy if the array of uploaded files and their details was posted with the other fields when creating a new record.

  • allanallan Posts: 63,353Questions: 1Answers: 10,444 Site admin
    Answer ✓

    Thanks for the clarification. Yes, the pre-built libraries will not obtain the file information at the point of committing the new or updated row. You would need to modify the server-side code to return that information and likely update the client-side with that additional information. It is stored in $.fn.dataTable.Editor.files.

    Allan

  • OrayiOrayi Posts: 6Questions: 1Answers: 0

    Thanks for the help, I guess that appending it client side is the best option for me as I've done above.

This discussion has been closed.