gpfup_file_error

  1. Description
  2. Usage
  3. Parameters
  4. Since
  5. Examples
    1. Log Failed Uploads
    2. Alert the User When an Upload is Rejected by the Server

Description

Do something when a file fails to upload.

Usage

window.gform.addAction( 'gpfup_file_error', function ( formId, fieldId, file, err, gpfupInstance ) {
	// Do something.
} );

Parameters

  • formId string|number

    The current form ID.

  • fieldId string|number

    The current File Upload field ID.

  • file object

    The Plupload file object that failed to upload.

  • err object

    The error that caused the failure.

  • err.code string|number

    The Plupload error code (e.g. plupload.FILE_SIZE_ERROR, plupload.FILE_EXTENSION_ERROR, plupload.HTTP_ERROR).

  • err.message string

    The error message.

  • err.status number

    The HTTP status code. Only available for HTTP failures; 0 indicates a transport failure rather than a response from the server.

  • gpfupInstance object

    The current GP File Upload Pro uploader instance for the field.

Since

This action is available since version 1.5.16.

Examples

Log Failed Uploads

Log the name of each file that fails to upload along with the reason.

window.gform.addAction('gpfup_file_error', function(formId, fieldId, file, err) {
	console.log('Upload failed for ' + file.name + ': ' + err.message);
});

Alert the User When an Upload is Rejected by the Server

Show a message only for HTTP failures on form 123.

window.gform.addAction('gpfup_file_error', function(formId, fieldId, file, err) {
	if (formId == 123 && err.code === plupload.HTTP_ERROR) {
		alert('“' + file.name + '” could not be uploaded. Please try again.');
	}
});