CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> ASP

 How To Rename an Uploaded File?

Print topic Send  topic

Author Message
afrausto

Posts: 66
Posted: 08/03/2006, 11:01 AM

Hello,

I'm using CCS 3.0/ASP/MS Access and Persits ASPUpload to upload files in a form. How does one rename an uploaded file before it is saved to the destination folder and database?

Thanks
Albert
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/03/2006, 4:00 PM

Although I am not an ASP builder I went to AspUpload.com and took a look at their manual http://www.aspupload.com/manual.html

I hope this might be useful to you.
But I have not used the Persist stuff as I do not do ASP.

Others might have more usefull info for you
Also, using the SEARCH in the top menu bar of this forum I found you:
search term:"change+upload+filename"

http://forums.codecharge.com/posts.php?post_id=59684&s_...upload+filename
http://forums.codecharge.com/posts.php?post_id=58815&s_...upload+filename

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Maybe
Posted: 08/03/2006, 6:19 PM

The easiest way is to modify Upload() function of clsFileUpload class in Classes.asp.
Replace this code line
NewFileName = GetValidFileName(f.FileName) & f.FileName
With
NewFileName = GetValidFileName(f.FileName) & Replace(f.FileName, "Find_Whatever", "New")

Hope this helps
afrausto

Posts: 66
Posted: 08/04/2006, 9:09 AM

Thanks for the suggestions everyone.

But I believe I found another solution as well. While doing some more research into this I found that I can change the filename within one of the Events > Before Process File.

Thanks again for your help.
View profile  Send private message
DonB
Posted: 08/04/2006, 9:05 PM

NOooooooo!. Just use the After Process File event and rename the file
there.

FYI, files are uploaded by the webserver to a temporary file in webserver
filespace, then it is moved over to you in YOUR 'temporary' folder (the
TemporaryFolder property of your Upload control). From there it is moved
again to the final destination (the FileFolder property of your Upload
control). Before/After Process File events are before and after the final
move operation. The file is moved and processed first, then the database
update is performed. So you can easily alter the filename using the event
structure. Altering the standard runtime code is (should be) a 'last
resort'.

--
DonB

http://www.gotodon.com/ccbth


"Maybe" <Maybe@forum.codecharge> wrote in message
news:644d2a0a775779@news.codecharge.com...
> The easiest way is to modify Upload() function of clsFileUpload class in
> Classes.asp.
> Replace this code line
> NewFileName = GetValidFileName(f.FileName) & f.FileName
> With
> NewFileName = GetValidFileName(f.FileName) & Replace(f.FileName,
> "Find_Whatever", "New")
>
> Hope this helps
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

afrausto

Posts: 66
Posted: 10/19/2006, 1:43 PM

I'm trying to change the filename within After Process File event but I'm not having any success. The file is uploaded, but the filename is not changed. Here's my code:

Dim PID,GA  
PID = CCGetParam("PID",Empty)  
GA = CCDLookup("GeographicArea","tblProjects","PID="& PID,DBconnDWCF)  
  
upload.FileUpload1.value = GA & "-" & PID & "-" & upload.FileUpload1.GetOriginFileName

Although I get the following error message:

An error occured when uploading file specified in FileUpload1. Error description: Microsoft VBScript runtime error, Wrong number of arguments or invalid property assignment.

The file is uploaded successfully, but the filename is not changed.

What am I do wrong.
View profile  Send private message
wkempees


Posts: 1679
Posted: 10/19/2006, 3:03 PM

Check the content of your GA and PID, are they really filled?
Also echo the upload.fileUpload1 string to check correctness of content.
Last but not least GetOriginFilename shouldn't that be GetOriginFileName?

Non ASP'er though.
Walter

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
afrausto

Posts: 66
Posted: 10/19/2006, 4:11 PM

The content is there and upload.FileUpload1 string value is valid. The reason I know this is that the file is uploaded and recorded in the database, but without the new filename adjustment. It maintains the original filename.

Thanks for the suggestions though.

Albert
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.