Pure ASP Upload 3 Support Product Page

This topic was archived by Teodor Kuduschiev on 7/1/2016 10:09:06 AM
Under consideration

Remove Special Characters from File Name

Shared 11 Jun 2007 15:19:16
1
likes this idea
11 Jun 2007 15:19:16 Mike Anderson posted:
How can I remove special characters from file names before upload? I have users that name their files with special characters that cause the upload to crash - particluarly ,~!@#$%^&*()+

I believe this was an option in the older version of Pure ASP upload.

Replies

Replied 11 Jun 2007 16:18:26
11 Jun 2007 16:18:26 Georgi Kralev replied:
Hi Mike,

Both versions of Pure Asp Upload (2 and 3) does not provide such functionality.

Regards,

Georgi Kralev

----------------------------------
Support - www.DMXzone.com
Replied 03 Jul 2007 03:57:27
03 Jul 2007 03:57:27 Mike Anderson replied:
I have been using version 1.09 until I just purchased v3 for the .NET compatibility. The older version had this feature. Will the newer version(s) offer it. It seems like a common need since I cannot control the way users name their files and they, of course, have no idea why they get the error.
Replied 03 Jul 2007 04:09:26
03 Jul 2007 04:09:26 Mike Anderson replied:
I just pulled this from your description/advertisement for PureASP Upload 2 Found under the Features and Highlights here: www.dmxzone.com/ShowDetail.asp?NewsId=1622

Automatically remove invalid chars from filename
All invalid characters used in the filename of the uploaded files are automatically removed. Only letters, numbers and _-. are allowed.

So...
Replied 03 Jul 2007 10:02:59
03 Jul 2007 10:02:59 Georgi Kralev replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I just pulled this from your description/advertisement for PureASP Upload 2 Found under the Features and Highlights here: www.dmxzone.com/ShowDetail.asp?NewsId=1622

Automatically remove invalid chars from filename
All invalid characters used in the filename of the uploaded files are automatically removed. Only letters, numbers and _-. are allowed.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Hi Mike,

Thank you for making the issue more clear. Indeed, Pure Asp Upload 2 was build-in feature for removing characters as:
$@&lt;&gt;[]{}():;=^|*!/\%?,'"
(I thought that you are talking about interface switch with which you can choose if you want to remove some characters from the file name)

Unfortunately, at this point this functionality is not implemented into Pure Asp Upload 3 (This was due to some users complains).
I have added this as a feature request into our bug-tracking system and it will be considered for future versions.

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote> I have been using version 1.09 until I just purchased v3 for the .NET compatibility.<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Have in mind that Pure Asp Upload 3 does not use .NET

Regards,

Georgi Kralev

----------------------------------
Support - www.DMXzone.com
Replied 03 Jul 2007 21:03:25
03 Jul 2007 21:03:25 Mike Anderson replied:
Thanks for your response. This feature is essential and I hope you can incorporate it soon in an upgrade. I have quite a few sites using the ASP Upload extension and the issue of special characters in the file name has become a problem since I upgraded to v3. Any idea when you may add this function to v3. I spent a decent amount to upgrade to v3 and the newest resize extension...

Anyway you can provide the code that removed special characters, or instructions on how to extract this from the v2 code?
Replied 04 Jul 2007 13:05:29
04 Jul 2007 13:05:29 Georgi Kralev replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Thanks for your response. This feature is essential and I hope you can incorporate it soon in an upgrade. I have quite a few sites using the ASP Upload extension and the issue of special characters in the file name has become a problem since I upgraded to v3. Any idea when you may add this function to v3. I spent a decent amount to upgrade to v3 and the newest resize extension...

Anyway you can provide the code that removed special characters, or instructions on how to extract this from the v2 code?
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Hi Mike,

The functionality that remove special characters is realized into the following function in incPureUpload.asp:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Function pau_RemoveInvalidChars(str)
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

To extract it you have just to copy the function and paste it at incPU3Class.asp (For example after the end of definition of function Class_Terminate).

Then you have to call it in function Save. For example you have to change the following lines:
FileExist = Fso.FileExists(absPath & FileName)
To:
FileExist = Fso.FileExists(absPath & pau_RemoveInvalidChars(FileName))

newFileName = absPath & m_FileName
To:
newFileName = absPath & pau_RemoveInvalidChars(m_FileName)

newFileName = Fso.GetBaseName(absPath & m_FileName) & "_" & num & "." & Fso.GetExtensionName(absPath & m_FileName)
To:
newFileName = Fso.GetBaseName(absPath & pau_RemoveInvalidChars(m_FileName)) & "_" & num & "." & Fso.GetExtensionName(absPath & m_FileName)

If Fso.FileExists(absPath & m_FileName) Then Fso.DeleteFile(absPath & m_FileName)
Fso.MoveFile m_TempFileName, absPath & m_FileName
ElseIf IsObject(m_Blob) Then
m_Blob.SaveToFile absPath & m_FileName, 2
End If
To:
If Fso.FileExists(absPath & pau_RemoveInvalidChars(m_FileName)) Then Fso.DeleteFile(absPath & pau_RemoveInvalidChars(m_FileName))
Fso.MoveFile m_TempFileName, absPath & pau_RemoveInvalidChars(m_FileName)
ElseIf IsObject(m_Blob) Then
m_Blob.SaveToFile absPath & pau_RemoveInvalidChars(m_FileName), 2
End If

I hope this will help you.

Note: This workaround comes without warranty or support of any kind

Regards,

Georgi Kralev

----------------------------------
Support - www.DMXzone.com
Replied 09 Feb 2008 01:35:24
09 Feb 2008 01:35:24 Chris Couture replied:
I tried the work around above but it didn't work. It still allowed files with a % sign to be uploaded. When my clients visitors try to download the files with % signs in them, it crashes.

Any work around for this?
Replied 04 Mar 2008 07:29:09
04 Mar 2008 07:29:09 Chris Couture replied:
George, please help!!!! They did it again!!!! My customer is trying to upload PDF's into the system I built for them that have the % sign in the file names. They upload file but can not be called using ASP when they try to download them. I would be happy replacing the % sign with the word percent in the file name but am unsure where to start.

Any help would be great!

Thanks,

Chris
Replied 17 Mar 2008 18:39:40
17 Mar 2008 18:39:40 Georgi Kralev replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
George, please help!!!! They did it again!!!! My customer is trying to upload PDF's into the system I built for them that have the % sign in the file names. They upload file but can not be called using ASP when they try to download them. I would be happy replacing the % sign with the word percent in the file name but am unsure where to start.

Any help would be great!

Thanks,

Chris
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Hi Chris,

The above work around should clear the following characters from the uploaded file name: $@&lt;&gt;[]{}():;=^|*!/\%?,'"
Therefore, if you have applied it correctly you should not have any problems.

Unfortunately, it is only a work around:
* It is not originally provided in Pure ASP Upload 3 and DMXzone.com does not support it.
* I cannot ensure any compatibility with the latest version of the extension.
* It is provided "as is", without warranty of any kind.

I can only advice you to:
1. Check if you have appropriately copied the pau_RemoveInvalidChars function from the code of Pure ASP Upload 2 (file incPureUpload.asp)
2. Make sure that you have make all the required changes into the Pure ASP Upload 3 code (file incPU3Class.asp)

Best regards,

Georgi Kralev

Homepage: gdkralev.googlepages.com
Replied 14 Oct 2009 15:23:14
14 Oct 2009 15:23:14 Jerry Smith replied:
It works good, but te problem is in the
pau.Fileds("xxx").Filename

there is the filename without stripped characters :-( so I can not get the real name from my ASP page :-(
Replied 15 Oct 2009 15:02:40
15 Oct 2009 15:02:40 Patrick Julicher replied:
Hi Jerry,

Please try the following. Open the file incPU3Class.asp from your ScriptLibrary. Scroll down to line 737. This should read Control.Name = strName. Please edit this line to:
Control.Name = pau_RemoveInvalidChars(strName)

Save and upload the file and try again.

Kind regards, Patrick

Replied 17 Oct 2009 23:15:18
17 Oct 2009 23:15:18 Jerry Smith replied:
Ok, I want to be honest, it was my mistake this time. Using your line says:

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'pau_RemoveInvalidChars'

D:\INETPUB\VHOSTS\xxx.xxx\HTTPDOCS\ADMIN\../ScriptLibrary/incPU3Class.asp, line 737

Do NOT use this line. It works without it, I just took the form field not the pau field, shame on me :-(

Please include this in future updates, because it is really smart to do this. I mean, uploading filename with "," in the middle makes error without this function. Maybe make user definable illegal characters so nobody will complain :-)

Edited by - Jerry Smith on 17 Oct 2009  23:15:35
Replied 18 Oct 2009 11:51:33
18 Oct 2009 11:51:33 Patrick Julicher replied:
Hi Jerry,

Thanks for your feedback and your honesty..... To be honest, I'm not familiar with the history of this function not being in updated version.

However, it has been included in future updates, as it seems to be working now? All you ask is to keep this function included in future updates/releases?

Kind regards, Patrick
Replied 18 Oct 2009 14:47:06
18 Oct 2009 14:47:06 Jerry Smith replied:
No, this feature is NOT INCLUDED in PUA3, it was there in PUA2, and in another topic Mr. George told us how to include it in PUA3, it is a difficult process as you have to replace about 15 places in your script.

As this function seems great to me so the customers "my filename, is this |.zip" gets translated to "myfilenameisthis.zip". The "," get's error every time and you can not know how customers want to upload files with "," in the filename :-((((

So the problem is it is NOT included I am including it by hand every time there is a new PUA3.

Mr. George told in the topic it was excluded because some users didn't like it.

So I see the solution to make it optional what characters should be stripped off filenames :-)
Replied 18 Oct 2009 18:51:35
18 Oct 2009 18:51:35 Patrick Julicher replied:
Hi Jerry,

I understand. I also saw you have sent your fix to George Petrov, so work is being done. Thanks for your cooperation!

Kind regards, Patrick
Replied 03 Dec 2009 21:29:08
03 Dec 2009 21:29:08 Jairo Ochoa replied:
Hello,

I think a function RemoveInvalidChars is a must have.

It could be enable/disable when set up the upload options if someone prefer not to be use.

But if you try to do SEO, a image filename never should be like "DSC23232.jpg" or "asd d a 78a$da.jpg", something like "description_of_the_picture.jpg" is much better.

So, this function should do 2 actions:

1) Remove invalid caracters (if enabled)
2) Rename it to some other name, which could be given from another form field (if enabled)

What do you think about it?

Regards.

Edited by - Jairo Ochoa on 03 Dec 2009  21:40:29
Replied 03 Dec 2009 22:10:23
03 Dec 2009 22:10:23 Jairo Ochoa replied:
Hello again,

I read some some other post and I get a fix, but it only works if SIP is also used


Function RemoveInvalidChars(inputString)

Dim i, s1, s2
outputString = inputString
s1 = "ÁÀÉÈÍÏÓÒÚÜÑáàèéíïóòúüñ<>[]{}():;=^|*¡!¿/\%¿?,'~$@#&+ "
s2 = "AAEEIIOOUUNaaeeiioouun_______________________________"
If Len(outputString) <> 0 Then
For i = 1 to Len(s1)
outputString = Replace(outputString,Mid(s1,i,1),Mid(s2,i,1))
Next
End If
outputString = Replace(outputString,"""","_"
outputString = Replace(outputString,"__","_"
RemoveInvalidChars = outputString

End Function


I call it at SIP script where the "sip1.Mask"

<%
' Smart Image Processor 2.0.3
Dim sip1
Set sip1 = New ImageProcessor
sip1.ScriptFolder = "../ScriptLibrary"
sip1.Component = "AspJpeg"
sip1.Source = "upload"
sip1.UploadFields = ""
sip1.GetFiles
While sip1.HasFiles
sip1.LoadFromSource
sip1.Resize 720, 720, true
sip1.Overwrite = true
sip1.Mask = "##path##" & RemoveInvalidChars(UploadFormRequest("myNewName") & ".jpg"
sip1.SaveJPEG 85
sip1.MoveNext
Wend
Set sip1 = Nothing
%>

Now it would be great that it worked in cases with PAU standalone, without PAU.

Regards

Edited by - Jairo Ochoa on 03 Dec 2009  22:11:30
Replied 03 Dec 2009 22:32:18
03 Dec 2009 22:32:18 George Petrov replied:
Hi Jairo,

We actually included a remove invalid characters function in the latest Pure ASP Upload version.

So download the latest and you should be all fine.

Greetings,
George
Replied 08 Dec 2009 18:34:45
08 Dec 2009 18:34:45 Jairo Ochoa replied:
Quote
We actually included a remove invalid characters function in the latest Pure ASP Upload version.


Hi George,

I do work with last version but ... which is this function name? I cannot find it.

Besides, the suggestion of the ability to set a filename instead of using the orignal as the file stored at local hard disk ...
I think it is great because to do SEO, the best name for an image is the name to descript what the image shows.
"sunset_in_the_beach.jpg" is better than "DSC234234.jpg".

If you check the fix I made it works with SIP nor with PAU, and also has a problem, if two images are named as sunset_in_the_beach.jpg, the second one overwrites the first one, so I have to make a new fix and and make a new function to generate a random number to be added to the filename

sip1.Mask = "##path##" & RandomNumber(0,999) & "_" & RemoveInvalidChars(UploadFormRequest("newName" )) & ".jpg"


So, from my point of view.

1) PAU should replace invalid chars
2) PAU should be able to set a new filename
3) If this new filename already exist, it should add something like "_1", "_2"


As you say, PAU can do the first point, but I do not know how.

I hope you find it useful.

Regards,

Jairo
Replied 11 Dec 2009 23:20:52
11 Dec 2009 23:20:52 Patrick Julicher replied:
Quote1) PAU should replace invalid chars
2) PAU should be able to set a new filename
3) If this new filename already exist, it should add something like "_1", "_2"


Hi Jairo,

The Replace function cannot be called seperately. This should work automatically when using the Upload extension.
Regarding the last 2 points, you are right that these do work with SIP. I will add them to the PAU wish list for future updates.

Kind regards, Patrick
Replied 25 Feb 2010 18:54:02
25 Feb 2010 18:54:02 Gary Block replied:
QuoteHi Jairo,

We actually included a remove invalid characters function in the latest Pure ASP Upload version.

So download the latest and you should be all fine.

Greetings,
George


I have the latest version of Pure ASP Upload (3.0.15) but there are still spaces in file names. How can spaces be removed?
Replied 17 Oct 2010 14:18:56
17 Oct 2010 14:18:56 Ivan Halen replied:
Me too, I noticed that there are still spaces in the uploaded filenames: how can we avoid this?
Replied 31 Oct 2010 18:45:20
31 Oct 2010 18:45:20 Chris Sanlon replied:
you can add spaces to the list of characters to be removed simply by changing the line:

Invalid = "$@&<>[]{}():;=^|*!/\%?,'""" & chr(8)

to

Invalid = " $@&<>[]{}():;=^|*!/\%?,'""" & chr(8)

(notice the extra space before the $ sign. This line is in the Function pau_RemoveInvalidChars(str) in the incPU3Class.asp - around line 1900.
Replied 27 Nov 2010 12:57:41
27 Nov 2010 12:57:41 Ivan Halen replied:
Thanks Chris, I'll give it a try
Replied 09 Feb 2012 05:17:18
09 Feb 2012 05:17:18 Hans Kiesouw replied:
Hi there, you may also want to add the # to the list, as this also prevents the image from showing.

Reply to this topic