Forums

ASP

This topic is locked

Pure ASP Upload..Trim white space??

Posted 02 Jun 2003 17:49:26
1
has voted
02 Jun 2003 17:49:26 Katherine Williams posted:
Hi there, and thanks in advance,

I've got Pure ASP Upload working great with the Rename Uploaded Files SB, but I'm having a problem with trimming whte space on the renamed file name.

I set up my page so that when the user uploads their resume, it renames the file using their App_ID (User Name). the problem lies in that the User Name allows for up to 30 characters. Because of this, there is white space between the renamed file name, and the extension (ex: kwilliams .doc)

Does anyone know of a way to solve this? Thanks for any help.

KWilliams

Replies

Replied 03 Jun 2003 17:09:49
03 Jun 2003 17:09:49 Patrick Woldberg replied:
I allready replied to your email you have send.

You probably use char as datatype, use varchar instead.

--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Manager at DMXzone.com
--------------------------------------------------
Replied 03 Jun 2003 22:06:33
03 Jun 2003 22:06:33 ollie wenger replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Hello Katherine,

You probably use char as datatype in the database, you should use varchar instead.

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

Patrick,

As I stated in my email reply, I changed both the App_ID & Attach_Resume fields in the DB table from a datatype of char to varchar, but it made no difference.

I also took off the Rename SB completely to see if it was actually related to the rename SB, or something on my side. When I did that, it saved the file without a space between the filename and extension. Is there some code that I can add into the incPUAddOn file to correct this? Thanks Patrick.

KWilliams
Replied 04 Jun 2003 10:54:54
04 Jun 2003 10:54:54 Patrick Woldberg replied:
I will check the rename function to see if I can find anything strange in it and will let you know about it by email.

--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Manager at DMXzone.com
--------------------------------------------------
Replied 04 Jun 2003 15:53:59
04 Jun 2003 15:53:59 Katherine Williams replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Hi Katherine,

Are there any strange characters in the filename?
The Upload extensions converts several strange characters to spaces

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

No, the filename is Resume.doc, and their's no other weird characters in that filename. When I just upload the filename without renaming it, it works fine without adding all of those spaces between the filename & extension. It's only when I add the Rename SB that it adds all of those spaces between the App_ID & extension. This is the code that I have on the ASP Upload page itself that renames the file:
&lt;%
// *** Rename Uploaded Files 1.7.0
if (String(Request.QueryString("GP_upload") != "undefined" {
var REUF_path = ""
var REUF_nameConflict = "over"
var REUF_renameMask = Session("App_ID" + ".##ext##"
RenameUploadedFiles(REUF_path,REUF_nameConflict,REUF_renameMask);
}
%&gt;

I'll work around with it a bit to see if I can make any progress. If you come up with any other ideas, that would be very helpful. Thanks for all of your help.

KWilliams
Replied 04 Jun 2003 16:38:04
04 Jun 2003 16:38:04 Katherine Williams replied:
Hi Patrick,

I've been testing a few different things this morning, and this is what I've come up with so far:
When I change this code:
var REUF_renameMask = Session("App_ID" + ".##ext##"
To a static renamed filename instead of the session variable, like this:
var REUF_renameMask = "_myFile" + ".##ext##"
it renames it fine. It's only when it uses the App_ID that it has a problem renaming the file. So I tried to trim the Session Variable like this...

var REUF_renameMask = trim(Session("App_ID") + ".##ext##"

..but I get the following error message:
Microsoft JScript runtime error '800a138f' Object expected

Do you think I'm going in the right direction? Why am I getting this error message when I try to trim the Session Variable? Thanks Patrick.

KWilliams
Replied 06 Jun 2003 10:43:10
06 Jun 2003 10:43:10 Patrick Woldberg replied:
Trim is not available in Javascript. Try the following:

Add this code somewhere in the beginning:

&lt;SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT&gt;
function DoTrim(str, side)
dim strRet
strRet = str

If (side = 0) Then
strRet = LTrim(str)
ElseIf (side = 1) Then
strRet = RTrim(str)
Else
strRet = Trim(str)
End If

DoTrim = strRet
End Function
&lt;/SCRIPT&gt;

Then change the:

var REUF_renameMask = Session("App_ID" + ".##ext##"

To:

var REUF_renameMask = DoTrim( Session("App_Id" ,2) + ".##ext##"

This is the way Macromedia trims in Javascript

--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Manager at DMXzone.com
--------------------------------------------------
Replied 06 Jun 2003 18:08:36
06 Jun 2003 18:08:36 Katherine Williams replied:
Hi Patrick,

Guess what?? IT WORKED...IT WORKED...IT WORKED!!! Now everything is complete. Thank you so much for all of your help. You're a great resource for DMXZone!!!

KWilliams

Reply to this topic