CGBetterForms- uploads with spaces

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
afrimax1
Forum Members
Forum Members
Posts: 19
Joined: Fri May 22, 2015 4:35 pm

CGBetterForms- uploads with spaces

Post by afrimax1 »

I installed CMSMS v2.2.11 and CGBetterForms v1.10.4 for a client website.

The form allows a visitor to fill in their information and upload a resume in PDF form to apply for listed jobs. The client gets and email notification with the form details and a link to the resume.

The process works perfectly unless the user has a space in the PDF file name. The space ends the link in the email to client and they are unable to retrieve the PDF.

My-Resume.pdf creates a link to clientsite.com/path/My-Resume.pdf. That works fine.

However, uploading My Resume.pdf creates a link to clientsite.com/path/My

Any suggestions on how to get rid of the space?

Thanks!
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1076
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: CGBetterForms- uploads with spaces

Post by DIGI3 »

You should be able to use |cms_escape:'url' on the filepath variable, so something like:

Code: Select all

{$myfile|cms_escape:'url'}
will convert my/path/to/file name.pdf to my/path/to/file%20name.pdf

Documentation for Smarty's escape is https://www.smarty.net/docsv2/en/langua ... ier.escape
Not getting the answer you need? CMSMS support options
afrimax1
Forum Members
Forum Members
Posts: 19
Joined: Fri May 22, 2015 4:35 pm

Re: CGBetterForms- uploads with spaces

Post by afrimax1 »

Great!

But where do I put this code? Where is the relevant filepath variable to change?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1076
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: CGBetterForms- uploads with spaces

Post by DIGI3 »

I'm making some assumptions here without knowing your exact setup, but it should do the job. Open the form in CGBetterForms and go to the Handlers tab. One of them is likely an email handler, you can click on it and will see the template used to generate the email. Find the line that generates the link to the file and modify it there.

There are other options - you could rename the file on upload, or during/after form processing, but both of these would require some development knowledge. Encoding the link is probably the easiest.
Not getting the answer you need? CMSMS support options
afrimax1
Forum Members
Forum Members
Posts: 19
Joined: Fri May 22, 2015 4:35 pm

Re: CGBetterForms- uploads with spaces

Post by afrimax1 »

thanks for the response and apologies for coming back to this so late. I tried as I understood your suggestion, but cannot get it working.

Installed CGBetterForms and used it fresh out of the box. Created an upload field named 'Resume' to upload resumes. No alterations of any kind to the code. Works perfectly when a PDF file is uploaded with no spaces at all.

to test your suggestion:

1. Went to the CGBetterForms--> the form--> Handlers--> email results to specified addresses

2. Converted {$Resume} line- which works fine for files with no spaces- and tried it as {$Resume|cms_escape:'url'}

It comes back with the full path, but with each special character marked up (spaces, colons, slashes, etc.).

Results also do not come back as a link, just comes back as a plain-text path.

3. Converted escape into a 'href=' but that does not work at all.

Any other suggestions? I feel like we are getting close.
Attachments
Screenshot- Handlers.jpg
afrimax1
Forum Members
Forum Members
Posts: 19
Joined: Fri May 22, 2015 4:35 pm

Re: CGBetterForms- uploads with spaces

Post by afrimax1 »

Here is the email I get.

First result is a broken link.

Second result is plain text.

Third result does not show up as a link.
Attachments
Screenshot- results.jpg
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1076
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: CGBetterForms- uploads with spaces

Post by DIGI3 »

The documentation for |cms_escape (which is just a customized version of Smarty's |escape) can be found here: https://www.smarty.net/docs/en/language ... escape.tpl

It's possible I just chose the wrong parameter, try urlpathinfo maybe.
Not getting the answer you need? CMSMS support options
afrimax1
Forum Members
Forum Members
Posts: 19
Joined: Fri May 22, 2015 4:35 pm

Re: CGBetterForms- uploads with spaces

Post by afrimax1 »

Got it! Will play around with it. Thank you so much for pointing me in the right direction.

I do think, however, that the module should have this capability built in.

Thank you!
afrimax1
Forum Members
Forum Members
Posts: 19
Joined: Fri May 22, 2015 4:35 pm

Re: CGBetterForms- uploads with spaces

Post by afrimax1 »

After trying several different parameters to cms_escape, I still could not get this to work.

Added a bug report to the module, as this should come working out of the box anyhow.

Thanks for the help.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3304
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: CGBetterForms- uploads with spaces

Post by velden »

In my opinion the module should return the actual value.

You as the website developer should then properly format it for your specific use.

BTW: note that some email clients try to properly create a link from a string looking like a link. You can't blame the module developer for the mail client failing that.

If you only want to replace spaces then I'd suggest to use

Code: Select all

{$Resume|replace:' ':'%20'}
afrimax1
Forum Members
Forum Members
Posts: 19
Joined: Fri May 22, 2015 4:35 pm

Re: CGBetterForms- uploads with spaces

Post by afrimax1 »

1. I am not blaming the module developer, I am just trying to solve a problem. It does attempt to create a link, but that link is truncated and, therefore, does not work with gmail or outlook.

This is not about blame at all, it is simply attempting to get it to work for my client. I use CGBetterForms on at least 5 sites and it works wonderfully. This is the first time I have had this request and problem.

2. {$Resume|replace:' ':'%20'} WORKED PERFECTLY!

Thank you!
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12678
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: CGBetterForms- uploads with spaces

Post by Dr.CSS »

You could also do this to remove all spaces...

|replace:' ':''
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
Image
Post Reply

Return to “Modules/Add-Ons”