Forums / General Questions / how to add file upload to contact us page?

how to add file upload to contact us page?

Views: 2,798

Results 1 to 7 of 7
17 Apr 2012, 10:38 PM
#1
warroyo90 avatar

warroyo90

New Zenner

Join Date:
Jan 2012
Posts:
59
Plugin Contributions:
0

how to add file upload to contact us page?

Hi,

I know this question has been asked before but i have read pages of threads and most are old and end with no definite answer.

what I would like to do is simply add a upload file option to the contact us form. the file could be stored in a specified folder and then the regular email sent maybe with a modification saying that a file has been uploaded. if anyone has a simple solution to just adding an upload file option to the contact us form please let me know.

thank you

17 Apr 2012, 11:03 PM
#2
warroyo90 avatar

warroyo90

New Zenner

Join Date:
Jan 2012
Posts:
59
Plugin Contributions:
0

Re: how to add file upload to contact us page?

the reason this is necessary is because I will be modifying the contact us form to be a new define_page that will be a request a quote form. this i know how to do. the customer will be able to put in their info and upload a spreadheet including the quantity vendor and part#. the reason for having a file upload would be so the customer can attach a excel spreadsheet. I do not need the file to be sent as an attachment although if it is possible that would be great but a simple file upload to a location on my server and an email saying it has been uploaded with customer info is all.

17 Apr 2012, 11:54 PM
#3
warroyo90 avatar

warroyo90

New Zenner

Join Date:
Jan 2012
Posts:
59
Plugin Contributions:
0

Re: how to add file upload to contact us page?

also i found this function zen_draw_file_field() could this be used?

18 Apr 2012, 1:54 PM
#4
davowave avatar

davowave

New Zenner

Join Date:
Mar 2009
Posts:
90
Plugin Contributions:
0

Re: how to add file upload to contact us page?

It's always a bit of a risk allowing anyone to upload files to your server so be careful and read up so you know what you are doing. This isn't specifically a zencart issue. If you google for php file upload you will find out more information.

It might be a little more complicated than you perhaps think it is, you could always try elance or odesk

18 Apr 2012, 8:56 PM
#5
warroyo90 avatar

warroyo90

New Zenner

Join Date:
Jan 2012
Posts:
59
Plugin Contributions:
0

Re: how to add file upload to contact us page?

well I managed to do it. I ended up replicating the contact us page as a new page called request_quote. form there I modified the form for my needs and the instructions above. threw out anything I didnt need and replaced contact us instances with my new page name and FILENAME constant. after that I found a nice jquery php upload plugin that does ajax uploads of multiple files also has some pretty neat features. i inserted that in my new page after the form and specified its upload folder in the code. now I am able to upload a file with one click status bar appears and show that the file has been uploaded after that the user just hits send as usual and they never even notice that it was 2 separate forms. I then added a phrase in the email which specified a file has been uploaded and the usual contants that they enter. if anyone needs more detail or code just ask.

13 Jun 2012, 4:09 PM
#6
pub12 avatar

pub12

New Zenner

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

Re: how to add file upload to contact us page?

HI warroyo90,

I'm keen to do the same, could you please give me some details?

  1. Where did you add the new copy of contact_us
  2. How did you tell "zen cart" about your new php files?

Thanks, Pubs

19 Jun 2012, 5:28 AM
#7
warroyo90 avatar

warroyo90

New Zenner

Join Date:
Jan 2012
Posts:
59
Plugin Contributions:
0

Re: how to add file upload to contact us page?

sorry for the late response...

so to create a copy of the contact us page follow this tutorial (kind of) ...http://www.zen-cart.com/wiki/index.php/Creating_new_pages . so this tutorial shows how to create a new page in zen cart (very helpful by the way) look in the directories specified to add new files and you will find ones labeled contact_us transfer them to your computer and change the names to lets say upload_file so you would have :
(make sure to be consistent with naming...)

includes/modules/pages/upload_file/header_php.php(keep this the same) just change folder name before header_php.php to your new name
includes/templates/yourtemplate/templates/tpl_upload_file_default.php
includes/extra_datafiles/upload_file.php(you will have to edit some of the defines in this page)
includes/languages/english/upload_file.php(alos modify defines to fit your needs)

now you should have a page https://www.yoursite.com/index.php?main_page=upload_file

it shoudl look just like the contact us page.

now you can edit the info in tpl_upload_file_default to fit what you need. as for the upload part its a bit of a hack but works.

I used a ajax upload script https://github.com/valums/file-uploader download the files place the js in includes/modules/pages/upload_file/
place the css in your templates css folder labeled upload_file.css

this will ensure the js and css are only loaded on that page

next create a folder in somewhere in your structure called uploadPhp or soemthing and add the upload php file that was contained in the download in the same folder create a folder called uplaods or something of the sort.

go into the upload.php file and go to the bottom of the file and change the uplaod directory to the name of that folder ex. uploads/

next open the tpl_upload_file_default.php file and instantiate the file uploader and create a div in the page with the proper id

u should now have a working file upload

I even added a hidden input field that says a file has been uploaded to the server so the email that i get lets me know I have a file

hope this works for you let me know if you have any questions