Image upload image thumbnail preview for Multi-File Upload [RESOLVED]

You can find out how to get the new temp file name here: Temp file upload random string - #4 by richardw8k

If you want to make the temp file url available to your code snippet without exposing where the files are actually stored you could use the following PHP code snippet which will prepare a secure gf-download URL for the file server side and add it to the new response param that is available to the JS based gform_file_upload_markup filter with the new build.

add_action( 'gform_post_multifile_upload', function ( $form, $field, $uploaded_filename, $tmp_file_name ) {
	GFCommon::log_debug( sprintf( 'GFAsyncUpload::upload(): File upload complete. temp_filename: %s  uploaded_filename: %s ', $tmp_file_name, $uploaded_filename ) );
	wp_send_json( array(
		'status' => 'ok',
		'data'   => array(
			'temp_filename'     => $tmp_file_name,
			// Decoding filename to prevent file name mismatch.
			'uploaded_filename' => str_replace( "\\'", "'", urldecode( $uploaded_filename ) ),
			'temp_preview_url'  => $field->get_download_url( GFFormsModel::get_upload_url( $form['id'] ) . '/tmp/' . $tmp_file_name ),
		),
	) );
}, 10, 4 );
2 Likes