Days
Hours
Minutes
Seconds
x

Froala Editor v4.2.0 is Here LEARN MORE

Skip to content

PHP SDK Image Reference

upload ($fileRoute, $options)

Returns: Object

Method used to upload image to the specified location on disk.

Parameters:


  • $fileRoute

    The path relative to the $_SERVER['DOCUMENT_ROOT'] global variable were the image should be uploaded.

    Type: String

  • $options

    This parameter is optional. It can be used to pass custom options for the image upload.

    Type: Array


$options parameter:

  • fieldname

    The field name from the $_FILES global variable.

    Type: String
    Default:
    "file"
  • validation

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

    Type: Array or Function
    Default:
    array(
      'allowedExts' => array('gif', 'jpeg', 'jpg', 'png', 'svg', 'blob'),
      'allowedMimeTypes' => array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/svg+xml')
    )
    
  • resize

    An array with custom options to scale the image. Available options are the ones from Imagick::resizeImage. Example:

    array(
      'columns' => 200,
      'rows' => 200,
      'filter' => imagick::FILTER_LANCZOS,
      'blur' => 1,
      'bestfit' => TRUE
    )

    Type: Array
    Default:
    NULL

Response

If the upload is completed successfully, the method returns an object with the absolute path to the uploaded image. If an error occurs, the method returns an error.

try {
  $response = FroalaEditor_Image::upload('/uploads/');
  echo stripslashes(json_encode($response));
}
catch (Exception $e) {
  http_response_code(404);
}

delete ($src)

Returns: Boolean

Method used to delete an image from disk.

Parameters:


  • $src

    The path relative to the $_SERVER['DOCUMENT_ROOT'] global variable to the image that should be deleted.

    Type: String

list ($folderPath, $thumbPath)

Returns: Array

Method used to list all images from disk.

Parameters:


  • $folderPath

    The path relative to the $_SERVER['DOCUMENT_ROOT'] global variable from where the images are being loaded.

    Type: String

  • $thumbPath

    The path relative to the $_SERVER['DOCUMENT_ROOT'] global variable from where the image thumbs are being loaded.

    Type: String

Response

If the request is completed successfully, the method returns an array with images. If an error occurs, the method returns an error.

try {
  $response = FroalaEditor_Image::list('/uploads/');
  echo stripslashes(json_encode($response));
}
catch (Exception $e) {
  http_response_code(404);
}

[class^="wpforms-"]
[class^="wpforms-"]
[bws_google_captcha]
<div class="gglcptch gglcptch_v2"><div id="gglcptch_recaptcha_767874185" class="gglcptch_recaptcha"></div> <noscript> <div style="width: 302px;"> <div style="width: 302px; height: 422px; position: relative;"> <div style="width: 302px; height: 422px; position: absolute;"> <iframe src="https://www.google.com/recaptcha/api/fallback?k=6Ld6lNoUAAAAAM626LfCOrnkBFJtYZAKESFCjgv_" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"></iframe> </div> </div> <div style="border-style: none; bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px; background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px; height: 60px; width: 300px;"> <textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px !important; height: 40px !important; border: 1px solid #c1c1c1 !important; margin: 10px 25px !important; padding: 0px !important; resize: none !important;"></textarea> </div> </div> </noscript></div>
[class^="wpforms-"]
[class^="wpforms-"]
[bws_google_captcha]
<div class="gglcptch gglcptch_v2"><div id="gglcptch_recaptcha_1821151983" class="gglcptch_recaptcha"></div> <noscript> <div style="width: 302px;"> <div style="width: 302px; height: 422px; position: relative;"> <div style="width: 302px; height: 422px; position: absolute;"> <iframe src="https://www.google.com/recaptcha/api/fallback?k=6Ld6lNoUAAAAAM626LfCOrnkBFJtYZAKESFCjgv_" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"></iframe> </div> </div> <div style="border-style: none; bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px; background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px; height: 60px; width: 300px;"> <textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px !important; height: 40px !important; border: 1px solid #c1c1c1 !important; margin: 10px 25px !important; padding: 0px !important; resize: none !important;"></textarea> </div> </div> </noscript></div>
[class^="wpforms-"]
[class^="wpforms-"]
[bws_google_captcha]
<div class="gglcptch gglcptch_v2"><div id="gglcptch_recaptcha_2060333234" class="gglcptch_recaptcha"></div> <noscript> <div style="width: 302px;"> <div style="width: 302px; height: 422px; position: relative;"> <div style="width: 302px; height: 422px; position: absolute;"> <iframe src="https://www.google.com/recaptcha/api/fallback?k=6Ld6lNoUAAAAAM626LfCOrnkBFJtYZAKESFCjgv_" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"></iframe> </div> </div> <div style="border-style: none; bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px; background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px; height: 60px; width: 300px;"> <textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px !important; height: 40px !important; border: 1px solid #c1c1c1 !important; margin: 10px 25px !important; padding: 0px !important; resize: none !important;"></textarea> </div> </div> </noscript></div>