Jump to content

Progressbar when uploading downloadable file


Artus2000

Recommended Posts

Hello,

 

I need to add progress bar to Back Office showing when I upload a downloadable product. Prestashop (my version 1.4.7.3) doesn't show anything when product is uploading. When i upload big files it is important to show the progress.

 

Some time ago, one guy do for me this modification. Script works fine, but I find some issue after detailed investigation. Unfortunately i can't contact with this person. He is unavailable.

 

He use free uploadify jquery script (uploadify.com). Uploader works fine, but there is some problem when i'd like edit product after saving it. I can't delete file and upload new one.

 

On screenshot shows what is the problem - step by step. And below, i pasted pieces of code connected to this modification in /admin_folder/tabs/AdminProducts.php. There are some other files need to work with this uploader, but I think the problem is in this file.

 

Someone can help me?

 

 

function uploadFile()
{
 $.ajaxFileUpload (
  {
url:'./uploadProductFile.php',
secureuri:false,
fileElementId:'virtual_product_file',
dataType: 'xml',
success: function (data, status)
{
 data = data.getElementsByTagName('return')[0];
 var result = data.getAttribute("result");
 var msg = data.getAttribute("msg");
 var fileName = data.getAttribute("filename");	 if (result == "error")
 {
  $("#upload-confirmation").html('<p>error: ' + msg + '</p>');
 }
 else
 {
  $('#virtual_product_file').remove();
  $('#virtual_product_file_label').hide();
  $('#file_missing').hide();
  $('#delete_downloadable_product').show();
  $('#virtual_product_name').attr('value', fileName);
  $('#upload-confirmation').html(
   '<a class="link" href="get-file-admin.php?file='+msg+'&filename='+fileName+'"><?php echo $this->l('The file') ?> "' + fileName + '" <?php echo $this->l('has successfully been uploaded') ?></a>' +
   '<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="' + msg + '" />');
 }
}
  }
 );
}
//]]>
</script>
<script type="text/javascript" src="themes/jquery.uploadify-3.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="themes/uploadify.css">

<script>
$(function() {$('#custom_file_upload').uploadify({
'swf'	  : 'themes/uploadify.swf',
'uploader' : 'themes/uploadify.php',
 'cancelImage'	  : 'themes/uploadify-cancel.png',
 'multi'		  : false,
 'auto'		   : true,
 'queueID'		: 'custom-queue',
 'queueSizeLimit' : 20,
 'simUploadLimit' : 20,
 'sizeLimit'   : 102400000000,
 'removeCompleted': false,
 'onDialogClose'   : function(queue) {
  $('#status-message').text(queue.filesQueued + ' files have been added to the queue.');
}, 'onQueueComplete'  : function(stats) {
 $.get('themes/uploadify.php?idp=pokaz_nazwe_produktu',function(wynik){
  $('#virtual_product_name').val(wynik);
 });
}
});

 

 

1.

This screen shows situation after uploaded first product.

1.png

 

2.

This screen shows when I edit product after saving.

2.png

 

3.

This screen shows what is happened when i deleted the file.

3.png

 

 

4.

I upload second file and when I again try edit product i I have no way for delete the file.

4.png

Link to comment
Share on other sites

  • 4 years later...
Hello,
I have a problem, which is not very similar but I wanted to upload multiple files.
I am developing a module that among other functions I want to send me an email to the client that I selected and with the files they attach.
When I upload files through code:
$ Fields_form = array (
'Form' => array (
'Legend' => array (
'Title' => $ this-> l ('Email Receipt Form'). '=> Client Name:'. $ Name_customer. ' - Email: '. $ Email_customer.' - Client language: '. $ Name_lang,
'Icon' => 'icon-cogs'
),
'Input' => array (
Array (
'Type' => 'text',
'Label' => $ this-> l ('Email Client'),
'Name' => 'email',
'Search' => false,
'Orderby' => false,
'Align' => 'center',
),
Array (
'Type' => 'text',
'Label' => $ this-> l ('E-mail copy'),
'Name' => 'ACCOUNT_EMAIL',
'Search' => false,
'Orderby' => false,
'Align' => 'center',
'Desc' => $ this-> l ('Check if this is the email you want to send a copy of the email sent.')
),
Array (
'Type' => 'file',
'Label' => $ this-> l ('Attach documents'),
'Name' => 'FILE',
'Search' => false,
'Orderby' => false,
'Align' => 'center',
'Desc' => $ test,
(to be continued)
 
 It works flawlessly, but only sends one attachment at a time.
I wanted to now send more than one attachment through what I did in the following code:
$ Fields_form = array (
'Form' => array (
'Legend' => array (
'Title' => $ this-> l ('Email Receipt Form'). '=> Client Name:'. $ Name_customer. ' - Email: '. $ Email_customer.' - Client language: '. $ Name_lang,
'Icon' => 'icon-cogs'
),
'Input' => array (
Array (
'Type' => 'text',
'Label' => $ this-> l ('Email Client'),
'Name' => 'email',
'Search' => false,
'Orderby' => false,
'Align' => 'center',
),
Array (
'Type' => 'text',
'Label' => $ this-> l ('E-mail copy'),
'Name' => 'ACCOUNT_EMAIL',
'Search' => false,
'Orderby' => false,
'Align' => 'center',
'Desc' => $ this-> l ('Check if this is the email you want to send a copy of the email sent.')
),
Array (
'Type' => 'file',
'Label' => $ this-> l ('Attach documents'),
'Name' => 'FILE',
'Search' => false,
'Orderby' => false,
'Align' => 'center',
'Desc' => $ test,
'Ajax' => true,
'Multiple' => true,
),
(to be continued)
This code uploads multiple files but I can not get it to work.
I can not get the second image code to work.
Someone can help me"?
Thank you

I have a problem, which is not very similar but I wanted to upload multiple files.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...