cancel
Showing results for 
Search instead for 
Did you mean: 

Can't upload images with Help Desk

SOLVED

Can't upload images with Help Desk

Hi to everyone. I've installed the free version of Magebuzz Help Desk extension with the web setup wizzard on my Magento 2.1.5. The extension looks cool, the tickets are sent/received ok, but they all arrive without the attachments. First I thougt it was my bad configuration, but then I tried the online demo on Magebuzz site

http://www.magebuzz.com/helpdesk-magento-2.html

and I saw their demo doesn't transfert attachments as well. I've tried to contact them without success they don't respond. But I would really like to have this feature working. Has anyone used this extension, could somebody help me out?

 

So far, I've tried to debug the javascript on the page, it uses multifile jQuery http://www.fyneworks.com/jquery/multifile/

and can see my attachments on the list under file selection field, I can also see the files are saved to object in jquery script, but they are somehow lost on the way to the server when submitting.2017-03-09 19_13_52-My Tickets.png

Well to be honest, I can't figure out how they are supposed to be transmitted to the server. There is JS code which fires on the click ob "Submit Ticket" button, but can't figure out how should that upload the images to the server.

2017_03_09_19_20_32_My_Tickets.png

Any help is highly welcome, much thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Can't upload images with Help Desk

Ufff, I solved this one. The problem was wrong array processing in some php files of the extension. Well, maybe it even works in php 5.5, don't have time to test that, but it definitely doesn't in php 7.0. The files in question are (inside of the folder where plugin Help Desk is installed)

./Controller/Ticket/CreatePost.php

./Controller/Ticket/PostReply.php

./Controller/Adminhtml/Ticket/Save.php

 

They all contain the code to upload the attachment files to the server, it is similar in all of them, here is the original relevant part of that:

                // Process uploading files
                if ($messageId = $message->getId()) {
                    $filesRequest = $this->getRequest()->getFiles('attachments');

                    if (isset($filesRequest['name']) && is_array($filesRequest['name'])) {
                        //rearrange the files
                        foreach ($filesRequest['name'] as $i => $name) {

                            if ($filesRequest['error'][$i] == 4)
                                continue;

                            $file = array(
                                'name' => $filesRequest['name'][$i],
                                'type' => $filesRequest['type'][$i],
                                'tmp_name' => $filesRequest['tmp_name'][$i],
                                'error' => $filesRequest['error'][$i]
                            );

                            $this->_helpdeskHelper->uploadAttachment($file, $currentId, $messageId);
                        }
                    }
                }

And here is the fix:

                // Process uploading files
                if ($messageId = $message->getId()) {
					//>custom_file_entry
					$filesRequest2 = $this->getRequest()->getFiles('attachments');

					foreach($filesRequest2 as $filesRequest) {
						if (isset($filesRequest['name'])) {				

		                    //rearrange the files
	                        if ($filesRequest['error'] == 4)
	                            continue;

	                        $file = array(
	                            'name' => $filesRequest['name'],
	                            'type' => $filesRequest['type'],
	                            'tmp_name' => $filesRequest['tmp_name'],
	                            'error' => $filesRequest['error']
	                        );

	                        $this->_helpdeskHelper->uploadAttachment($file, $currentId, $messageId);
		                }
					}
					//<custom_file_entry
                }

I didn't want to do any optimisation fo the code, just made it working as supposed Smiley Wink Hope this helps someone.

View solution in original post

1 REPLY 1

Re: Can't upload images with Help Desk

Ufff, I solved this one. The problem was wrong array processing in some php files of the extension. Well, maybe it even works in php 5.5, don't have time to test that, but it definitely doesn't in php 7.0. The files in question are (inside of the folder where plugin Help Desk is installed)

./Controller/Ticket/CreatePost.php

./Controller/Ticket/PostReply.php

./Controller/Adminhtml/Ticket/Save.php

 

They all contain the code to upload the attachment files to the server, it is similar in all of them, here is the original relevant part of that:

                // Process uploading files
                if ($messageId = $message->getId()) {
                    $filesRequest = $this->getRequest()->getFiles('attachments');

                    if (isset($filesRequest['name']) && is_array($filesRequest['name'])) {
                        //rearrange the files
                        foreach ($filesRequest['name'] as $i => $name) {

                            if ($filesRequest['error'][$i] == 4)
                                continue;

                            $file = array(
                                'name' => $filesRequest['name'][$i],
                                'type' => $filesRequest['type'][$i],
                                'tmp_name' => $filesRequest['tmp_name'][$i],
                                'error' => $filesRequest['error'][$i]
                            );

                            $this->_helpdeskHelper->uploadAttachment($file, $currentId, $messageId);
                        }
                    }
                }

And here is the fix:

                // Process uploading files
                if ($messageId = $message->getId()) {
					//>custom_file_entry
					$filesRequest2 = $this->getRequest()->getFiles('attachments');

					foreach($filesRequest2 as $filesRequest) {
						if (isset($filesRequest['name'])) {				

		                    //rearrange the files
	                        if ($filesRequest['error'] == 4)
	                            continue;

	                        $file = array(
	                            'name' => $filesRequest['name'],
	                            'type' => $filesRequest['type'],
	                            'tmp_name' => $filesRequest['tmp_name'],
	                            'error' => $filesRequest['error']
	                        );

	                        $this->_helpdeskHelper->uploadAttachment($file, $currentId, $messageId);
		                }
					}
					//<custom_file_entry
                }

I didn't want to do any optimisation fo the code, just made it working as supposed Smiley Wink Hope this helps someone.