CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 FileUpload Component Bug (Filenames with Spaces)

Print topic Send  topic

Author Message
jjrjr1


Posts: 942
Posted: 06/01/2008, 11:00 AM

Hi

Just wanted to mention a bug in the FileUpload Control. When I reported it to YesSoftware it was a version 3 problem. I sent them a one line fix it did not seem to appear in Version 4. So I thought I would describe it here.

It has to do with uploading files with spaces in the name on linux/Unix servers, which Unix type systems do not like. (Probably not a problem on Windows servers since Windows has always been ok with filenames and spaces. I have not verified this)

This problem does not seem to exist if you only upload and retrieve files within CCS applications (Have not tried it myself or verified it. I did not want to take any chances and I have implemented this fix for all cases)

However, if you are doing some server side processing in the after process event on your Linux/Unix server, such as FFMPEG for video conversion, bad things will happen. A filename sitting on a server like this will cause wierd problems one is that the filesystem will think you created 2 files separated by the space but the inodes point to one file. (This is probably why the CCS only upload and download will probably work ok)

eg: upload file = "this file.mpg" is legal on windows systems and CCS will upload it.
on your server you will see Linux/Unix thinks there are 2 files one called "this" and one
called "file.mpg"

This means any server side processing will fail since your upload filename is not found on the server.

You could do client side validation in your scripts and not allow upload of filenames with spaces..... UUK! terible idea. (This is what YesSoftware Support suggested)

What I did was modify the fileupload class in Classes.PHP so the upload component replaces all Linux/Unix unfriendly chracters in the upload filename generated by CCS with the underscore "_" using strreplace().

You can find the place in Classes.PHP since it is where CSS adds the timestamp to the filename before uploading. After the timestamp is added to the filename prior to uploading, do the string replace of spaces and any other offending characters.

If you need any more info, let me know.

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
kirchaj

Posts: 215
Posted: 06/10/2008, 7:35 PM

jjrjr1,

I have had the very same problem and asked the very same question. Unfortunately I did not find the solution you did. I would love to know the details of this solution and see if I could implement it also.

One other thing. I did find that there are other characters besides spaces that cause problems. I cannot give an exhaustive list, but several are %^&#. Did you experience this problem and will your solution take care of this also?

Thanks for sharing your good news.

TK
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/10/2008, 10:31 PM

Hi

You have to modify Classes.php. You find that under the common files in the directory tree in the IDE.

Open Classes.php and locate the FileUpload Class.

The find the location where the method sets the ActualFilename to the filename plus the timestamp.

Directly after that code just do a string replace of space with maybe _ underscore.

If you have trouble finding that area to make the change, ket me know

Have fun

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/10/2008, 10:33 PM

With respect to the other characters you mentioned just do a string replace for each of those. However the ones you mentioned I think are also illegal in Windows anyway so you should never come across those.


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.