Title: amtekitsolutions's Replies | WordPress.org

---

# amtekitsolutions

  [  ](https://wordpress.org/support/users/amtekitsolution/)

 *   [Profile](https://wordpress.org/support/users/amtekitsolution/)
 *   [Topics Started](https://wordpress.org/support/users/amtekitsolution/topics/)
 *   [Replies Created](https://wordpress.org/support/users/amtekitsolution/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/amtekitsolution/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/amtekitsolution/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/amtekitsolution/engagements/)
 *   [Favorites](https://wordpress.org/support/users/amtekitsolution/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Job Postings] Crashing Website When Sending Application](https://wordpress.org/support/topic/crashing-website-when-sending-application/)
 *  Thread Starter [amtekitsolutions](https://wordpress.org/support/users/amtekitsolution/)
 * (@amtekitsolution)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/crashing-website-when-sending-application/#post-10464620)
 * After some research it’s my dam Godaddy host that blocks .docx attachments, would
   it be possible to write some custom code like this.
 *     ```
       if (!function_exists('wfu_file_upload_output_handler')) {
       	function wfu_file_upload_output_handler($output) {
       		$output .= "
       <script type='text/javascript'>
       var load_JSZip = function() {
       	var head = document.getElementsByTagName('head')[0];
       	var theScript = document.createElement('script');
       	theScript.type = 'text/javascript';
       	theScript.src = 'https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.4/jszip.min.js';
       	head.appendChild(theScript);
       }();
       if (!window['wfu_selectbutton_changed_orig']) {
       	window['wfu_selectbutton_changed_orig'] = wfu_selectbutton_changed;
       	wfu_selectbutton_changed = function(sid, usefilearray) {
       		wfu_selectbutton_changed_orig(sid, 1);
       		if (typeof GlobalData.WFU[sid].filearrayprops == 'undefined')
       			GlobalData.WFU[sid].filearrayprops = Array();
       	}
       }
       if (!window['wfu_HTML5UploadFile_cont_orig']) {
       	window['wfu_HTML5UploadFile_cont_orig'] = wfu_HTML5UploadFile_cont;
       	wfu_HTML5UploadFile_cont = function(sid, unique_upload_id) {
       		wfu_continue_processing_files(sid, unique_upload_id, 0);
       	}
       }
       function wfu_continue_processing_files(sid, unique_upload_id, start) {
       	var farr = wfu_get_filelist(sid);
       	var i = start;
       	var process_id = -1;
       	while (i < farr.length) {
       		var ext = farr[i].name.replace(/^.*?(\.([^.]*))?$/, '$2').toLowerCase();
       		if (ext == 'docx') {
       			process_id = i;
       			break;
       		}
       		i++;
       	}
       	if (process_id == -1) window['wfu_HTML5UploadFile_cont_orig'](sid, unique_upload_id);
       	else {
       		var zip = new JSZip();
       		zip.file(farr[process_id].name, farr[process_id]);
       		zip.generateAsync({type: 'blob', compression: 'DEFLATE', compressionOptions: {level: 9}}).then(function (docxfile) {
       			GlobalData.WFU[sid].filearray[process_id] = new File([docxfile], farr[process_id].name);
       			wfu_continue_processing_files(sid, unique_upload_id, process_id + 1);
       		}, function error(e) {
       			console.log('error');
       		});
       	}
       }
       </script>
       	";
       		return $output;
       	}
       	add_filter('_wfu_file_upload_output', 'wfu_file_upload_output_handler', 10, 1);
       }
       if (!function_exists('wfu_after_file_loaded_handler')) {
       	function wfu_after_file_loaded_handler($changable_data, $additional_data) {
       		$file = $additional_data["file_path"];
       		$name = wfu_basename($file);
       		$ext = wfu_fileext($name);
       		if ( strtolower($ext) == "docx" ) {
       			$zip = new ZipArchive;
       			$contents = "";
       			if ($zip->open($file) === true) {
       				$contents = $zip->getFromName($name);
       				$zip->close();
       			}
       			$ret = false;
       			if ( $contents != "" )  $ret = file_put_contents($file, $contents);
       			if ( $ret === false ) {
       				$changable_data["error_message"] = "upload failed!";
       			}
       		}
   
       		return $changable_data;
       	}
       	add_filter('wfu_after_file_loaded', 'wfu_after_file_loaded_handler', 10, 2); 
       }
       ```
   
 * This would automatically zip the docx file in the browser before uploading to
   the media folder in word-press and get round the issue.
 * Regards,
 * Carl A. Heath

Viewing 1 replies (of 1 total)