Zen Cart Logo
Forums / All Other Contributions/Addons / Add a upload module on contact us page

Add a upload module on contact us page

Views: 4,155

Results 1 to 16 of 16
10 Jun 2008, 6:36 AM
#1
als88 avatar

als88

New Zenner

Join Date:
May 2007
Posts:
36
Plugin Contributions:
0

Add a upload module on contact us page

I know Zen Chart got a upload module for product.

But if I want to Add a upload module on contact us page.
that will allow the customer upload some file with a message and their email address.

If someone know how ,please give me some tips, thanks

16 Jun 2008, 10:43 PM
#2
noone avatar

noone

New Zenner

Join Date:
Jun 2008
Location:
Utah, US.
Posts:
26
Plugin Contributions:
0

Re: Add a upload module on contact us page

BUMP

I am currently attempting to do just that, having some problems though, if i get it, I'll let you know.

and if any else has this, PLEASE pass it along.

17 Jun 2008, 2:59 AM
#3
noone avatar

noone

New Zenner

Join Date:
Jun 2008
Location:
Utah, US.
Posts:
26
Plugin Contributions:
0

Re: Add a upload module on contact us page

Got it!!!!

upload images on contact page + it will email you the name(s) of the files uploaded.

With

Popup (animated.gif) progress bar

gimme a while to put it together for ya.....

anyone interested?

17 Jun 2008, 5:06 AM
#4
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: Add a upload module on contact us page

NooNe:

Got it!!!!

upload images on contact page + it will email you the name(s) of the files uploaded.

With

Popup (animated.gif) progress bar

gimme a while to put it together for ya.....

anyone interested?
Sounds good..please share..
:smile:

19 Jun 2008, 5:25 AM
#5
als88 avatar

als88

New Zenner

Join Date:
May 2007
Posts:
36
Plugin Contributions:
0

Re: Add a upload module on contact us page

NooNe:

Got it!!!!

upload images on contact page + it will email you the name(s) of the files uploaded.

With

Popup (animated.gif) progress bar

gimme a while to put it together for ya.....

anyone interested?

Hi NooNe, please tell me how, thanks

19 Jun 2008, 1:18 PM
#6
noone avatar

noone

New Zenner

Join Date:
Jun 2008
Location:
Utah, US.
Posts:
26
Plugin Contributions:
0

Re: Add a upload module on contact us page

Hiya, alsBB – Misty,

Okie, I am writing this mod in 2 sections – Section 1) upload mod, and section 2) “dummy” progress bar mod.

Section 1) Upload Mod

  1. In includes/templates/YOUR_TEMPLATE/templates/tpl_contact_us_default.php
    Find:
<label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL; ?></label>
<?php echo zen_draw_input_field('email', ($error ? $_POST['email'] : $email), ' size="40" id="email-address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<label for="enquiry"><?php echo ENTRY_ENQUIRY . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label>
<?php echo zen_draw_textarea_field('enquiry', '30', '7', '', 'id="enquiry"'); ?>

Change to:

<label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL; ?></label>
<?php echo zen_draw_input_field('email', ($error ? $_POST['email'] : $email), ' size="40" id="email-address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<label for="enquiry"><?php echo ENTRY_ENQUIRY . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label>
<?php echo zen_draw_textarea_field('enquiry', '30', '7', '', 'id="enquiry"'); ?></fieldset><fieldset>
<? if ($_SESSION['customer_id'] != ''){ ?>
<label class="inputLabel" for="image1"><?php echo 'Front image' ?></label>
<?php echo zen_draw_file_field('ufile[]'); ?>
<br class="clearBoth" />
<label class="inputLabel" for="image2"><?php echo 'Back image' ?></label>
<?php echo zen_draw_file_field('ufile[]'); ?>
<br class="clearBoth" />

Then in includes/modules/pages/contact_us/header_php.php

Find:

<?
if (isset($_GET['action']) && ($_GET['action'] == 'send')) { ?>
<?

change to::

<?
if (isset($_GET['action']) && ($_GET['action'] == 'send')) { ?>
<?
 $path1= "images/ YOUR_UPLOAD_FILE ".$HTTP_POST_FILES['ufile']['name'][0];
$path2= "images/YOUR_UPLOAD_FILE ".$HTTP_POST_FILES['ufile']['name'][1];

//copy file to where you want to store file
copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);

then find:

OFFICE_FROM . "\t" . $name . "\n\n" .
OFFICE_EMAIL . "\t" . $email_address . "\n\n" .
'------------------------------------------------------' . "\n\n" .

and change to:

OFFICE_FROM . "\t" . $name . "\n\n" .
OFFICE_EMAIL . "\t" . $email_address . "\n\n" .
 'Front image; '.$HTTP_POST_FILES['ufile']['name'][0] .  "\n\n" .
'Back image; '.$HTTP_POST_FILES['ufile']['name'][1] .  "\n\n" .
'------------------------------------------------------' . "\n\n" .

When we added <?php echo zen_draw_file_field('ufile[]'); ?> the name ufile[] is loading & POSTing your image into an array, using this method you can add 100+ of the zen_draw_file_fields without having to rename them.

When the customer hits the “send now” button, the cart goes to the “send” portion of the cart and this is where we catch your newly POSTed files.

$HTTP_POST_FILES['ufile']['name'][0]; is the first ufile[] that you placed on the first page (Zero is the first number…lol) and then is goes to HTTP_POST_FILES['ufile']['name'][1]; and then[2], then [3] and so on, up too 100+..

You will need to change images/YOUR_UPLOAD_FILE into images/uploaded or into images/contact and make sure that you have the same name on your file folder in your “images/”

MOD dummy progress bar:
In this section you will also need to ceate a file “popup.html”
Section 2-A) in popup.html add:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

</head><center><img src="/images/popup_image.png" /><br/><? // my header/logo image
<img src="/images/progress_bar_animated.gif" width="500" height="30" /><br/> <? // my animated.gif progress bar found on the internet
(Depending on your file size, this page may take up to 10 minutes to refresh).</center> <? // me asking the customer no to touch anything more
</body>
</html>

then upload it in your ROOT docs (next to your main index page).

Section 2-B) In includes/templates/YOUR_TEMPLATE/templates/tpl_contact_us_default.php

Find:

</fieldset>

<div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_SEND, BUTTON_SEND_ALT); ?></div>
<div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div>

and change to:

</fieldset>
<script type="text/javascript"><!--
document.write("<div style='display:none' id='moreinfo'>");
//-->
</script><? include ('popup.html'); ?><script type="text/javascript"><!--
document.write("</div>");
//--></script>
</fieldset>
<div class="buttonRow forward"><? echo zen_image_submit(BUTTON_IMAGE_SEND, BUTTON_SEND_ALT,'','onclick="document.getElementById(\'moreinfo\').style.display = \'block\';"') ;?> </div>
<div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div>

What this script does is includes and “hides” popup.html and then when the customer presses the “send now” button, it “shows” popup.html.

This is a very basic progress bar setup, my customers upload 30m – 350m files and it takes a while, and this stops them from thinking it’s a “Dead page” and isn’t doing anything, and re-clicking the send now button again.

I hope this helps…….

19 Jun 2008, 1:44 PM
#7
noone avatar

noone

New Zenner

Join Date:
Jun 2008
Location:
Utah, US.
Posts:
26
Plugin Contributions:
0

Re: Add a upload module on contact us page

Just a note:

if you are attempting to have customers upload images during the purchase process, i highly recommend learning about and using attributes, as the cart uses them extensively, and what can be done with them is simply amazing.

https://www.zen-cart.com/tutorials/index.php?article=57

it is much easier for you and your customer in the long run, than the code that i have written.

19 Jun 2008, 9:00 PM
#8
astarkley avatar

astarkley

New Zenner

Join Date:
Nov 2006
Posts:
72
Plugin Contributions:
0

Re: Add a upload module on contact us page

Yes I'm very interested in knowing how to do what you've done.

19 Jun 2008, 9:04 PM
#9
noone avatar

noone

New Zenner

Join Date:
Jun 2008
Location:
Utah, US.
Posts:
26
Plugin Contributions:
0

Re: Add a upload module on contact us page

Its there ^^^^^^^^^^^ Looky up

20 Jun 2008, 11:24 PM
#10
als88 avatar

als88

New Zenner

Join Date:
May 2007
Posts:
36
Plugin Contributions:
0

Re: Add a upload module on contact us page

cool!!!
Thanks very much for shareing!
I will try your way
I thing hundred of people in here would like to improve the upload module.
you are the hero

20 Jun 2008, 11:49 PM
#11
noone avatar

noone

New Zenner

Join Date:
Jun 2008
Location:
Utah, US.
Posts:
26
Plugin Contributions:
0

Re: Add a upload module on contact us page

My Pleasure.

21 Jun 2008, 4:30 AM
#12
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: Add a upload module on contact us page

NooNe:

My Pleasure.
Not tested yet, but thanks for sharing.
:clap:

23 Jun 2008, 9:25 PM
#13
noone avatar

noone

New Zenner

Join Date:
Jun 2008
Location:
Utah, US.
Posts:
26
Plugin Contributions:
0

Re: Add a upload module on contact us page

A Note on the progress bar (bug discovered):

Depending on your version, this may work

<div class="buttonRow forward"><? echo zen_image_submit(BUTTON_IMAGE_SEND, BUTTON_SEND_ALT,'','onclick="document.getElementById(\'moreinfo\').style.display = \'block\';"') ;?> </div>

Or you may have to remove the

,''
To look like this
<div class="buttonRow forward"><? echo zen_image_submit(BUTTON_IMAGE_SEND, BUTTON_SEND_ALT,'onclick="document.getElementById(\'moreinfo\').style.display = \'block\';"') ;?> </div>
6 Aug 2010, 12:58 AM
#14
danielle avatar

danielle

Totally Zenned

Join Date:
Oct 2004
Posts:
973
Plugin Contributions:
0

Re: Add a upload module on contact us page

NooNe:

Hiya, alsBB – Misty,

Okie, I am writing this mod in 2 sections – Section 1) upload mod, and section 2) “dummy” progress bar mod.

Section 1) Upload Mod

  1. In includes/templates/YOUR_TEMPLATE/templates/tpl_contact_us_default.php
    Find:

<label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL; ?></label>

<?php echo zen_draw_input_field('email', ($error ? $_POST['email'] : $email), ' size="40" id="email-address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?> <br class="clearBoth" /> <label for="enquiry"><?php echo ENTRY_ENQUIRY . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label> <?php echo zen_draw_textarea_field('enquiry', '30', '7', '', 'id="enquiry"'); ?> ``` > > Change to: > ```php <label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL; ?></label> <?php echo zen_draw_input_field('email', ($error ? $_POST['email'] : $email), ' size="40" id="email-address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?> <br class="clearBoth" /> <label for="enquiry"><?php echo ENTRY_ENQUIRY . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label> <?php echo zen_draw_textarea_field('enquiry', '30', '7', '', 'id="enquiry"'); ?></fieldset><fieldset> <? if ($_SESSION['customer_id'] != ''){ ?> <label class="inputLabel" for="image1"><?php echo 'Front image' ?></label> <?php echo zen_draw_file_field('ufile[]'); ?> <br class="clearBoth" /> <label class="inputLabel" for="image2"><?php echo 'Back image' ?></label> <?php echo zen_draw_file_field('ufile[]'); ?> <br class="clearBoth" /> ``` > > Then in includes/modules/pages/contact_us/header_php.php > > Find: > ```php <? if (isset($_GET['action']) && ($_GET['action'] == 'send')) { ?> <? ``` > > change to:: > ```php <? if (isset($_GET['action']) && ($_GET['action'] == 'send')) { ?> <? $path1= "images/ YOUR_UPLOAD_FILE ".$HTTP_POST_FILES['ufile']['name'][0]; $path2= "images/YOUR_UPLOAD_FILE ".$HTTP_POST_FILES['ufile']['name'][1];

//copy file to where you want to store file
copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);

> 
> then find:
> ```php
OFFICE_FROM . "\t" . $name . "\n\n" .
OFFICE_EMAIL . "\t" . $email_address . "\n\n" .
'------------------------------------------------------' . "\n\n" .

and change to:

OFFICE_FROM . "\t" . $name . "\n\n" .
OFFICE_EMAIL . "\t" . $email_address . "\n\n" .
'Front image; '.$HTTP_POST_FILES['ufile']['name'][0] . "\n\n" .
'Back image; '.$HTTP_POST_FILES['ufile']['name'][1] . "\n\n" .
'------------------------------------------------------' . "\n\n" .

> 
> 
> When we added <?php echo zen_draw_file_field('ufile[]'); ?> the name ufile[] is loading & POSTing your image into an array, using this method  you can add 100+ of the zen_draw_file_fields without having to rename them. 
> 
> When the customer hits the “send now” button, the cart goes to the “send” portion of the cart and this is where we catch your newly POSTed files.
> 
> $HTTP_POST_FILES['ufile']['name'][0]; is the first ufile[] that you placed on the first page (Zero is the first number…lol) and then is goes to HTTP_POST_FILES['ufile']['name'][1]; and then[2], then [3] and so on, up too 100+..
> 
> You will need to change images/YOUR_UPLOAD_FILE into images/uploaded or into images/contact and make sure that you have the same name on your file folder in your “images/”
> 
> 
> 
> MOD dummy progress bar: 
> In this section you will also need to ceate a file “popup.html”
> Section 2-A) in popup.html add:
> ```php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

</head><center><img src="/images/popup_image.png" /><br/><? // my header/logo image
<img src="/images/progress_bar_animated.gif" width="500" height="30" /><br/> <? // my animated.gif progress bar found on the internet
(Depending on your file size, this page may take up to 10 minutes to refresh).</center> <? // me asking the customer no to touch anything more
</body>
</html>

then upload it in your ROOT docs (next to your main index page).

Section 2-B) In includes/templates/YOUR_TEMPLATE/templates/tpl_contact_us_default.php

Find:

</fieldset> <div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_SEND, BUTTON_SEND_ALT); ?></div> <div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div> ``` > > and change to: > ```php </fieldset> <script type="text/javascript"><!-- document.write("<div style='display:none' id='moreinfo'>"); //--> </script><? include ('popup.html'); ?><script type="text/javascript"><!-- document.write("</div>"); //--></script> </fieldset> <div class="buttonRow forward"><? echo zen_image_submit(BUTTON_IMAGE_SEND, BUTTON_SEND_ALT,'','onclick="document.getElementById(\'moreinfo\').style.display = \'block\';"') ;?> </div> <div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div> ``` > > > What this script does is includes and “hides” popup.html and then when the customer presses the “send now” button, it “shows” popup.html. > > This is a very basic progress bar setup, my customers upload 30m – 350m files and it takes a while, and this stops them from thinking it’s a “Dead page” and isn’t doing anything, and re-clicking the send now button again. > > I hope this helps…….

I am trying to install this mod, but it's just not working. The image is not being uploaded, and the name of the image does not show up in the e-mail. The header_php.php is slightly different though, it looks like this now (version 1.3.9d):

if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
$name = zen_db_prepare_input($_POST['contactname']);
$email_address = zen_db_prepare_input($_POST['email']);
$enquiry = zen_db_prepare_input(strip_tags($_POST['enquiry']));

I tried implementing the changes in the mod so the file looks like this:

if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
$name = zen_db_prepare_input($_POST['contactname']);
$email_address = zen_db_prepare_input($_POST['email']);
$path1= "artwork_uploads/".$HTTP_POST_FILES['ufile']['name'][0];
$enquiry = zen_db_prepare_input(strip_tags($_POST['enquiry']));

//copy file to where you want to store file
copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);

But it is just not working. Did I modify the file incorrectly?

Thanks!

16 Jun 2012, 5:38 PM
#15
pub12 avatar

pub12

New Zenner

Join Date:
Jun 2012
Posts:
2
Plugin Contributions:
0

Re: Add a upload module on contact us page

Hello,

if anyone tried this http://www.zen-cart.com/showthread.php?100081-Add-a-upload-module-on-contact-us-page/page2 in latest version of PHP it will fail (learned the hard way).

Require to perform two updates:

  1. tpl_contact_us_defualt.php will require this change:

before:

<?php echo zen_draw_form('contact_us', zen_href_link(FILENAME_CONTACT_US, 'action=send') ); ?>

after:

<?php echo zen_draw_form('request', zen_href_link(FILENAME_REQUEST, 'action=send'), 'post', ' enctype="multipart/form-data"' ); ?>
  1. You need to add another hidden element:
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />

where value = max file size in bytes.

Then upload will work.

pubs

16 Jun 2012, 6:57 PM
#16
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Add a upload module on contact us page

Shouldn't that be ... ?> <?php echo zen_draw_form('request', zen_href_link(FILENAME_CONTACT_US, 'action=send'), 'post', ' enctype="multipart/form-data"' ); ?>

Also your max file size setting should be no greater than the equivalent value set in your php.ini file, otherwise the latter will override your value.

It may also be helpful to note that Zen Cart has a built-in class named "upload" for handling file uploads.