File upload

File upload

jtoler5jtoler5 Posts: 93Questions: 34Answers: 3

If I have Editor set to use an AJAX call to get the data, when uploading a file... should the url sent to server be different than AJAX I set? I have no problem getting, creating, editing, or deleting the data. Only problem is when I attempt to upload a file, it uses a completely different URL so it says route not found (using symfony).

->upload(
                                Upload::inst($dirPath . '__ID__.__EXTN__')
                                    ->db('uploads', 'id', array(
                                        'file_name' => Upload::DB_FILE_NAME,
                                        'file_size' => Upload::DB_FILE_SIZE,
                                        'web_path' => Upload::DB_WEB_PATH,
                                        'system_path' => Upload::DB_SYSTEM_PATH
                                    ))
                                    ->validator(Validate::fileExtensions(['pdf'], "Please upload a pdf file"))
                                    ->dbClean(function ($data) {
                                        // Remove the files from the file system
                                        for ($i = 0, $ien = count($data); $i < $ien; $i++) {
                                            unlink($data[$i]['systemPath']);
                                        }

                                        // Have Editor remove the rows from the database
                                        return true;
                                    })
                            )

Answers

  • kthorngrenkthorngren Posts: 21,374Questions: 26Answers: 4,957

    should the url sent to server be different than AJAX I set?

    Looking at the upload docs there is an optional option ajax which states this:

    Ajax URL or jQuery.ajax configuration object that should be used for the Ajax request to upload a file. If this is property is not give, the value from ajax is used.

    Sounds like you have the choice of what url to use.

    it uses a completely different URL so it says route not found

    Do you have the ajax option of the upload configured? Have you tried commenting it out so the ajax url is used?

    If you want to use a different url then you will need to setup the web server environment to support that route.

    Kevin

Sign In or Register to comment.