Page 4 of 6 FirstFirst ... 23456 LastLast
Results 31 to 40 of 57
  1. #31
    Join Date
    Mar 2011
    Location
    Pensacola, FL
    Posts
    88
    Plugin Contributions
    4

    Default Re: Adding Multiple Images to Custom form To be sent to Admin Email

    In the updated version of the plugin I included a simple example htaccess page to include in the images/uploads directory:
    Code:
    # To prevent malicious uploads, replace or add to the contents of .htaccess file in images/uploads directory with this one  
    # Edit FilesMatch list below as needed
    # Be sure the file is named .htaccess and not just htaccess
    
    # secure uploads directory
    <Files ~ ".*\..*">
    	Order Allow,Deny
    	Deny from all
    </Files>
    <FilesMatch "\.(jpg|jpeg|jpe|gif|png|tif|tiff)$">
    	Order Deny,Allow
    	Allow from all
    </FilesMatch>

  2. #32
    Join Date
    Sep 2008
    Location
    DownUnder, overlooking South Pole.
    Posts
    976
    Plugin Contributions
    6

    Default Re: Adding Multiple Images to Custom form To be sent to Admin Email

    Mutinyzoo

    The security side is largely covered by the link provided in Post 3 of this thread. I feel there is no need to reinvent the wheel.

    Just to clarify the upload test, the error message I received was for trying to upload an image of size 2040Kb (ie > 2Mb). I then proceeded to upload a slightly smaller image (ie < 2Mb), which succeeded with no error message.

    cheers

  3. #33
    Join Date
    Mar 2011
    Location
    Pensacola, FL
    Posts
    88
    Plugin Contributions
    4

    Default Re: Adding Multiple Images to Custom form To be sent to Admin Email

    I actually think that 2040kb translates to a tiny bit smaller than 2mb at least in UNIX terms. https://wiki.ubuntu.com/UnitsPolicy. Is used this converter.

  4. #34
    Join Date
    Mar 2011
    Location
    Pensacola, FL
    Posts
    88
    Plugin Contributions
    4

    Default Re: Adding Multiple Images to Custom form To be sent to Admin Email

    Inspired by above commentary from dw08gm, I've added some php code to verify acceptable extensions.

    At the moment the array of extension is just residing here in the header_php.php file. Could someone tell me where a better place to hold it would be, if the user is modifying it by hand?

    Code:
    $acceptable_extensions = array(
    	jpg, jpeg, gif, png, bmp, pdf, il, psd
    	);
    	foreach($_FILES as $key => $file) {
    	$file_ext = basename($_FILES['uploaded_file']['name']); 
    	$ext = substr($file_ext, strrpos($file_ext, '.') + 1);
    	 if ((zen_not_null($_FILES[$key]['tmp_name'])) && (in_array($ext, $acceptable_extensions))
    	 		&& $_FILES[$key]['tmp_name'] != 'none') {
    		  if ($_FILES[$key]['size'] <= MAX_FILE_UPLOAD_SIZE) {
    				  if ($upload = new upload($key, DIR_FS_UPLOADS)) {
    				$att_array[] = array('file' => $upload->destination . $upload->filename, 'name' => $upload->filename);
    			}
    			} else {
    			$Max_Size_Exceeded = $_FILES['uploaded_file']['name']." exceeds maximum file size of ".((MAX_FILE_UPLOAD_SIZE/1024)/1000)."MB. ";
    				  $messageStack->add('image_to_contact', $Max_Size_Exceeded.FILE_SIZE_CHECK_ERROR);
    				return false;
    		  }//EOF Filesize check
    	  }else{
    		if ( zen_not_null($_FILES[$key]['tmp_name']) && ($_FILES[$key]['tmp_name'] != 'none') ) {
    		$Unacceptable_Extension_Submitted = $_FILES['uploaded_file']['name']." contains the unnacceptable extension $ext.
    		Please submit a version with one of the following extensions: ".implode(", ", $acceptable_extensions);
    			  $messageStack->add('image_to_contact', $Unacceptable_Extension_Submitted.FILE_EXTENSION_SUBMISSION_ERROR);
    			return false;
    		}//EOF if acceptable extension
    	  }
    	}
    Thanks a bunch.

    Mike

  5. #35
    Join Date
    Sep 2008
    Location
    DownUnder, overlooking South Pole.
    Posts
    976
    Plugin Contributions
    6

    Default Re: Adding Multiple Images to Custom form To be sent to Admin Email

    Quote Originally Posted by mutinyzoo View Post
    I actually think that 2040kb translates to a tiny bit smaller than 2mb at least in UNIX terms. https://wiki.ubuntu.com/UnitsPolicy. Is used this converter.
    Forgot about the conversion factor (2040 <2048). But then whatever I did seemed to work.

    Nevertheless LadyBugMom provided a complete set of working files for file uploads. The only question I have is whether this file set is compatible with latter upgrades of php, mysql etc. This is not something that I have looked into.

    cheers

  6. #36
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Re: Adding Multiple Images to Custom form To be sent to Admin Email

    Great work with what has been made so far, what I'm trying to do now is modify the code to enable me to append something to the uploaded file name.

    as the upload form uses classes/uploads.php I don't think this is possible, I think I would have to upload without using the uploads.php file.

    What i am working towards is merging this image upload with http://www.zen-cart.com/downloads.php?do=file&id=109

    Essentially enabling customers to ask a question on their order and upload an image should they want to.


    The image file name could be renamed and its new numerical filename be stored in the Table: orders_status_history

    Then the file could be shown as a link in the admin with his customer comment.
    Last edited by DigitalShadow; 29 Jan 2015 at 07:06 PM.

  7. #37
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Re: Adding Multiple Images to Custom form To be sent to Admin Email

    As the customer is logged in to use order questions, the order number will be available

    The files could be uploaded into a folder name = to the order number

    But again to do that, I need to be able to modify either the filename or the upload directory.

    I think to do this I need to not use classes/uploads.php

    any thoughts?

  8. #38
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Adding Multiple Images to Custom form To be sent to Admin Email

    Yes, you can still use the upload class, but will have to do the upload handling manually.

    Instead of saying
    Code:
    $var = new upload($key, DIR_FS_UPLOADS);
    Use something like this instead:
    Code:
    $var = new upload; // without any parameters, it doesn't auto-upload and keep the same filename
    $var->set_file = $key;
    $var->set_destination=DIR_FS_UPLOADS;
    if ($var->parse() == true) {
      $var->set_filename('put the filename and extension here'); // this is where you manually supply the whole filename
      $var->save();
    } else {
      //die('could not manage uploads');
    }
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  9. #39
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Re: Adding Multiple Images to Custom form To be sent to Admin Email

    Quote Originally Posted by DrByte View Post

    Code:
    $var = new upload; // without any parameters, it doesn't auto-upload and keep the same filename
    $var->set_file = $key;
    $var->set_destination=DIR_FS_UPLOADS;
    if ($var->parse() == true) {
      $var->set_filename('put the filename and extension here'); // this is where you manually supply the whole filename
      $var->save();
    } else {
      //die('could not manage uploads');
    }
    I would need to use the same extension as the originally uploaded file?

    to start with I'm trying to get the uploaded file name to have test placed before it.

    so image.jpg would become testimage.jpg

    once I have got the basics, i could try putting the $order_id instead of test...

    Code:
    	$file_ext = basename($_FILES['uploaded_file']['name']); 
    	$ext = substr($file_ext, strrpos($file_ext, '.') + 1);
            $newname = 'test';
            $filename = $newname.$file_ext;
    
    $var = new upload; // without any parameters, it doesn't auto-upload and keep the same filename
    $var->set_file = $key;
    $var->set_destination=DIR_FS_UPLOADS;
    if ($var->parse() == true) {
      $var->set_filename('$filename'); // this is where you manually supply the whole filename
      $var->save();
    } else {
      //die('could not manage uploads');
    }

  10. #40
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Adding Multiple Images to Custom form To be sent to Admin Email

    For starters,
    Code:
    $var->set_filename('$filename');
    should be
    Code:
    $var->set_filename($filename);
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 
Page 4 of 6 FirstFirst ... 23456 LastLast

Similar Threads

  1. v139h New Contact Form Email - Messages not being sent?
    By jazzyman in forum General Questions
    Replies: 9
    Last Post: 6 Feb 2013, 05:28 PM
  2. email address - sent from, multiple emails
    By illusionest in forum Basic Configuration
    Replies: 2
    Last Post: 10 Nov 2010, 02:18 AM
  3. Adding Multiple Images though Admin that also works with zen lightbox 1.4
    By headyntl in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 3 Jul 2008, 07:58 AM
  4. EMail Admin the same Email message that is sent to customer
    By dubya01 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 21 Aug 2007, 03:47 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR