Form Builder - linking client to a...

User 2624978 Photo


Registered User
3 posts

Hey there,

In a form we have a file upload field. I have written an additional statement at the bottom of the notification_email to create a link to the file attached so that the client can DL it without accessing FTP or the server. Code is below:

<a href="http://www.site.com/formname/storage/files/[attachment]\">Attachment #1</a>

Unfortunately, this doesn't work when the user uploads a file with a space in the title. I just realized why - usually the browsers adds a "%20" to indicate a space but the form appears to be removing the first space in the filename so when I click the link it puts "%20" wherever there is a space, except where the first space appears.
Ex. Filename: jobs john doe.pdf

When I go to open the generated link the location appears are ".../storage/files/jobsjohn%20.pdf
So, it removed the first space but the rest remained. On the server the file is still uploaded as jobs john doe.pdf"

Anyone know how to help?

Thank you very much.
User 10077 Photo


Senior Advisor
1,096 posts

Any chance you can just have those using the forms not put spaces in the filenames?
ASK ME ANYTHING
I provide personalized help for Coffeecup Users including personal or group training for Site Designer, Web Form Builder and more via Zoom.
Email me at support@uscni.org or call 865-687-7698.

Did you know that Web Form Builder can be used for both simple and complicated forms and that it's not limited to the default fonts and buttons? Take a look at a form we developed for WindowTinting.com.
https://forms.windowtinting.com/forms/w … ppingcart/
User 2147626 Photo


Ambassador
2,958 posts

May or may not help you ...
http://gallery.technet.microsoft.com/scriptcenter/Encoding-and-Decoding-URL-99dc4256
Graphics for the web, email, blogs and more!
-------------------------------------
https://sadduck.com
User 2624978 Photo


Registered User
3 posts

Brian: We have added a large note next to the upload asking people to please not use spaces but there have been a few instances where people have uploaded and I have to go onto the server and send our client the files.

Gunsmoke: Any clue how this could be implemented into the Web Form Builder files?

Thanks for the help guys!
User 2147626 Photo


Ambassador
2,958 posts

Sorry, I'm a hacker not a coder. I'm sure it can be done, but Eric, Steve, Inger or one of the many other coders here would have to explain how. From everything I read if you manage to encode your url and change the spaces to pluses or the %20 then it should work. Ideally you should not have ANY spaces in file names anymore. But getting your users to understand that can be difficult, if not impossible! Hopefully someone will chime in here and help you out. Good luck! :cool:
Graphics for the web, email, blogs and more!
-------------------------------------
https://sadduck.com
User 38401 Photo


Senior Advisor
10,951 posts

I would open a support ticket on this as it actually sounds like it's not working correctly. I would think if it were going to strip one space it should strip them all and maybe the CC team isn't aware this is not happening.
User 187934 Photo


Senior Advisor
20,271 posts

I looked at the files and it appears that this can be altered on the utilities.inc.php page as long as your exporting your form and not using S-Drive. I would also agree with JoAnn in that it should strip all spaces from a file name.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 103173 Photo


VP of Software Development
0 posts

Form Builder is working exactly how it should. It just was never really designed for the function Melanie is looking for. We always preserve the original file name. I will add it to the list of possible enhancements for a future update.

Spaces are allowed in a file name and it uploads the file correctly. The issue comes from trying to link to that file over http where those spaces get encoded and creating a linking problem. That is something we never intended the software to be used as. It can be done but as you can see, there are some consequences when doing so.

My suggestion would be to use a PHP file in the folder that creates a directory listing. This would then allow you to see all files.

Learn the essentials with these quick tips for Responsive Site Designer, Responsive Email Designer, Foundation Framer, and the new Bootstrap Builder. You'll be making awesome, code-free responsive websites and newsletters like a boss.
User 187934 Photo


Senior Advisor
20,271 posts

Go to line 158 of the utilities.inc.php page and insert this

$basename = preg_replace('/\s+/', '', $basename);

directly below this
$basename = str_replace( '.', '_', $tmp ) . substr( $basename, $pos );

So when your done it will look like this.
158 $basename = str_replace( '.', '_', $tmp ) . substr( $basename, $pos );
159 $basename = preg_replace('/\s+/', '', $basename);
160 }

If your using mysql with this your table will show the original name with the space and the new file name without the space. It saves the file on your server without spaces. Your confirmation will also show the spaces removed.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.