Title: Error upload PDF
Last modified: November 7, 2022

---

# Error upload PDF

 *  Resolved [lightuono](https://wordpress.org/support/users/lightuono/)
 * (@lightuono)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/error-upload-pdf/)
 * Hi,
 *     ```
       When I try to upload a pdf file, I get the message
   
       An error occurred while loading. Try later.
   
       But if I refresh the page the file is still loaded. I tried to disable the ReMush plugin and I no longer have the error message.
   
       In the logs I have this,
   
       ==> resmushit.log <==
       [07-11-2022 11:01:21] Error! Incorrect attachment.1
   
       I use Imunify360 and this comes out
   
       [Mon Nov 07 12: 01: 19.065218 2022] [: error] [pid 6802: tid 139875927906048] [client xxxxx: 44578] [client 134.90.240.98] ModSecurity: Warning. Match of "rx ^ $" against "FILES_TMPNAMES: async-upload" required. [file "/etc/httpd/conf/modsecurity.d/rules/custom/000_i360_0.conf"] [line "155"] [id "77317957"] [msg "IM360 WAF: Track file upload || File: / var /imunify360/tmp_modsec/20221107-120119-Y2jlf7XUReyP2nbhYH9BaQAAABQ-file-WTpXEu||Size:3028||User:XXXX||SC:/var/www/vhosts/XXXX.edu.it/httpcupmins .php || T: APACHE || "] [severity" NOTICE "] [tag" service_i360custom "] [tag" noshow "] [hostname" www.XXXXX.edu.it "] [uri" / wp-admin / async -upload.php "] [unique_id" Y2jlf7XUReyP2nbhYH9BaQAAABQ "], referer: https://www.XXXXX.edu.it/wp-admin/upload.php
       ```
   

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [kodell](https://wordpress.org/support/users/kodell/)
 * (@kodell)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/error-upload-pdf/#post-16174918)
 * I just encountered the same issue today! I’ll put my statement here since it’s
   relevant. Until the devs fix it, I’ve manually applied a patch to my copy of 
   the `resmushit-image-optimizer/resmushit.php` file. (change all the `print_r(...)`
   statements to `print_r( ..., true )` )
 * resmushit.php.diff:
 *     ```
       --- resmushit.php.orig	2022-11-07 16:01:47.378952239 -0600
       +++ resmushit.php	2022-11-07 15:56:34.991002341 -0600
       @@ -108,14 +108,14 @@
   
        	$fileInfo = pathinfo(get_attached_file( $attachment_id ));
        	if(!isset($fileInfo['dirname'])) {
       -		rlog("Error! Incorrect file provided." . print_r($fileInfo), 'WARNING');
       +		rlog("Error! Incorrect file provided." . print_r($fileInfo, true), 'WARNING');
        		return $attachments;
        	}
        	$basepath = $fileInfo['dirname'] . '/';
        	$extension = isset($fileInfo['extension']) ? $fileInfo['extension'] : NULL;
   
        	if(!isset($attachments[ 'file' ])) {
       -		rlog("Error! Incorrect attachment." . print_r($attachments), 'WARNING');
       +		rlog("Error! Incorrect attachment." . print_r($attachments, true), 'WARNING');
        		return $attachments;
        	}
        	$basefile = basename($attachments[ 'file' ]);
       @@ -128,7 +128,7 @@
        	$statistics[] = reSmushit::optimize($basepath . $basefile, $force_keep_original );
   
        	if(!isset($attachments[ 'sizes' ])) {
       -		rlog("Error! Unable to find attachments sizes." . print_r($attachments), 'WARNING');
       +		rlog("Error! Unable to find attachments sizes." . print_r($attachments, true), 'WARNING');
        		return $attachments;
        	}
        	foreach($attachments['sizes'] as $image_style) {
       ```
   
 * Hopefully this helps anyone else who stumbles on this.
    -  This reply was modified 3 years, 6 months ago by [kodell](https://wordpress.org/support/users/kodell/).
      Reason: Markdown didn't format the way I expected. Removed 'diff' langcode
 *  [T0ny](https://wordpress.org/support/users/t0ny/)
 * (@t0ny)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/error-upload-pdf/#post-16176256)
 * Thanks. Kodell’s change solved the issue. I was getting `An error occurred while
   loading. Try later.` with each upload before applying it.
 *  Plugin Contributor [reSmush.it](https://wordpress.org/support/users/resmushit/)
 * (@resmushit)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/error-upload-pdf/#post-16176360)
 * Hi guys,
 * Thanks for this reporting, we’ll have a look quickly.
 * Regards,
    Charles
 *  Plugin Contributor [reSmush.it](https://wordpress.org/support/users/resmushit/)
 * (@resmushit)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/error-upload-pdf/#post-16177569)
 * Hello, this issue has been fixed!
    Sorry for the convenience :/
 * Regards,
    Charles
 *  Thread Starter [lightuono](https://wordpress.org/support/users/lightuono/)
 * (@lightuono)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/error-upload-pdf/#post-16177699)
 * worked!! Thanks 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Error upload PDF’ is closed to new replies.

 * ![](https://ps.w.org/resmushit-image-optimizer/assets/icon-256x256.png?rev=3049668)
 * [reSmush.it : The original free image compressor and optimizer plugin](https://wordpress.org/plugins/resmushit-image-optimizer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/resmushit-image-optimizer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/resmushit-image-optimizer/)
 * [Active Topics](https://wordpress.org/support/plugin/resmushit-image-optimizer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/resmushit-image-optimizer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/resmushit-image-optimizer/reviews/)

 * 5 replies
 * 4 participants
 * Last reply from: [lightuono](https://wordpress.org/support/users/lightuono/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/error-upload-pdf/#post-16177699)
 * Status: resolved