Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Output from messageStack from upload.php


Alk

Recommended Posts

Hello,

 

I would like to see the messages that get produced when doing a file upload, I am using the extensions functionality of the upload.php as follows:

 

$products_file = new upload('products_file', '' , '' ,'txt');

 

I can see from the database that this works OK as the filename is classed as 'object' when I try to upload a non txt file. However I would like to trap this error and inform the user immediately. From elsewhere I can see that the following code would be used:

 

            if ($messageStack->size('header') > 0) {
             ?>
                 <tr>
                   <td><?php echo $messageStack->output('header'); ?></td>
                 </tr>
                 <tr>
                   <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
                 </tr>
             <?php
           }    

 

... but I'm not certain what to enter for the '$class' parameter that gets passed as login.php does not pass this e.g.

 

Line 64 of login.php:

 

$messageStack->add(ERROR_FILETYPE_NOT_ALLOWED, 'error');

 

Any suggestions?

 

Cheers,

 

Al.

Link to comment
Share on other sites

Hi,

 

OK, so I was able to come to some kind of resolution with this, basically the original coding of the upload.php file failed to submit the first parameter when passing to the $messageStack, I included a parameter here i.e. 'upload' and now I get the output that I required, here is a code snippet:

 

        if (sizeof($this->extensions) > 0) {
         if (!in_array(strtolower(substr($file['name'], strrpos($file['name'], '.')+1)), $this->extensions)) {
           if ($this->message_location == 'direct') {
             $messageStack->add('upload', ERROR_FILETYPE_NOT_ALLOWED, 'error');
             
             if ($messageStack->size('upload') > 0) {
                  echo $messageStack->output('upload');
             }
           } else {
             $messageStack->add_session(ERROR_FILETYPE_NOT_ALLOWED, 'error');
           }

           return false;
         }
       }

 

Is that a bug in the upload.php code or am I missing something here? :huh:

 

Cheers,

 

Al

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...