Days
Hours
Minutes
Seconds
x

New Froala Editor v5.0.0 is here โ€“ Learn More

Skip to content
Froala Documentation

Node.JS SDK File Reference

upload (req, fileRoute, options, callback)

Method used to upload a file to the specified location on disk.

Parameters:


  • req

    In Node.JS, the uploaded file is available in the request received by your application.

    Type: Request Object

  • fileRoute

    The path of the file is relative to the root of your application.

    Type: String

  • options

    This parameter is optional. Use it to pass custom options for the file upload.

    Type: Object

  • callback

    A callback function call when the upload method finishes, or an error occurs. Invoked with (err, data).

    Type: Function


options parameter:

  • fieldname

    The field name from the request object.

    Type: String
    Default:
    "file"
  • validation

    A Javascript Object or a function used to validate the uploaded image. The Javascript Object specifies the allowed image extensions through allowedExts and the allowed mime types through allowedMimeTypes. The function should be invoked with: filePath, mimetype, and callback.

    Type: Object or Function
    Default:
    {
      'allowedExts': ['gif', 'jpeg', 'jpg', 'png', 'svg', 'blob'],
      'allowedMimeTypes': ['image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/svg+xml']
    }
    

delete (src, callback)

Method used to delete a file from disk.

Parameters:


  • src

    The file path available in the body of the request: request.body.src.

    Type: String

  • callback

    A callback function called when the delete method finishes, or an error occurs. Invoked with (err, data).

    Type: Function

Do you think we can improve this article? Let us know.

Sign up

Download the code by signing up for our newsletter

Sign up

Download the code by signing up for our newsletter

Note: By registering, you confirm that you agree to the processing of your personal data by Froala, Inc. - Froala as described in the Privacy Statement. Froala, Inc. - Froala is part of the Idera group and may share your information with its parent company Idera, Inc., and its affiliates. For further details on how your data is used, stored, and shared, please review our Privacy Statement.