Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

HELP ASP coding problem.

Posted on 2004-09-22
12
Medium Priority
?
529 Views
Last Modified: 2012-08-13
My Friend wrote me a file upload script in ASP(I've no programming skill) and he's on vacation now; that works great however I need to change the filename when it upload(now it use the file name + aa if duplicate) so I just wondering if anyone know how to modify the code to make it work?   I want to able to use today's date + sec for the file name when it upload for the file name.
It's not a homework or anything like that if you want I can give you my actual website and see how it look now.


Here's the HTML file code:
<html>
<head>

</head>

<body>

<form name="frmUpload" Method="Post" Enctype="multipart/form-data" Action="UploadAction.asp">
<table>
     <tr>
          <td>File</td>
          <td><input type="file" name="txtFileName"></td>
     </tr>
     <tr>
          <td>File</td>
          <td><input type="file" name="txtFileName1"></td>
     </tr>
     <tr>
          <td>Author</td>
          <td><input type="text" name="txtAuthor"></td>    
     </tr>
     <tr>
          <td>Author</td>
          <td><input type="text" name="txtAuthor1"></td>    
     </tr>
     <TR>
          <td COLSPAN="2" ALIGN="right"><INPUT TYPE="Submit" VALUE="Upload"></TD>
     </TR>
</table>
</form>
</body>
</html>



Here's the uploadaction.asp code:
<%@ Language=VBScript %>

<%
Option explicit
Response.Buffer = True
On Error Resume Next

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then

     Dim objUpload
     Dim lngMaxFileBytes
     Dim strUploadPath
     Dim ChangeLine
     Dim overwriteFile
     Dim chgFileName
     Dim limitFileType(2)
     Dim varResult

     lngMaxFileBytes = 600000
     strUploadPath = "c:\images"
     changeLine = "true"
     overwriteFile = "aa"
     chgFileName = ""
     'limitFileType(0) = "bmp"
     'limitFileType(1) = "jpg"
     'limitFileType(2) = "gif"

     
     Set objUpload = Server.CreateObject("chk.slfUpload")

     If Err.Number <> 0 Then

          Response.Write "The component wasn't registered"

     Else
          varResult = objUpload.DoUpload (lngMaxFileBytes, strUploadPath, changeLine, overwriteFile, chgFileName, limitFileType)
          Set objUpload = Nothing

          'Write the result
          Dim i
          For i = 0 to UBound(varResult,1)
               Response.Write varResult(i,0) & " : " & varResult(i,1) & "<br>"
          Next

     End If

End If
%>


Thanks.
0
Comment
Question by:pcchiu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12128457
for the overwrite, you could just do:

overwriteFile = Now() & ""


as for changing the name of the file at upload, I can only take a guess since I can't see the code for the component:


chgFileName = Now() & ""


FtB
0
 
LVL 9

Author Comment

by:pcchiu
ID: 12128534
It give me Error : Bad file name or number after the put in the overwriteFile = Now() & ""
and  Microsoft VBScript compilation error '800a03ea'
for chgFileName = Now() &

Actually I've no problem for the overwriteFile and the whole thing I want is to change the filename before it get upload to the server so the user can not use the fxxk.jpg or some bad name for the file and I may use the number for the filename once I found out how it works.

Hmmm that's the two files and the .dll file from my friend and he won't be back until the next month...

Thanks for your help.   Also I can increase the points if anyone can solve that for me.



0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12128575
The problem is that I can't see the code for the .dll.

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12128598
One other option is to use a different upload component:

http://www.taka.nl/programming/asp/comparing_fileupload.asp
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12128609
0
 
LVL 9

Author Comment

by:pcchiu
ID: 12128637
I don't think I can see the code from the .dll either only the one have the orginial file can do that?  
O well how about is there any FREE asp upload coding around the world is easy to use just like that one upload form and one asp form and one dll?  

Thanks.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12128642
>>I don't think I can see the code from the .dll either only the one have the orginial file can do that?  <<

That is correct.

>>O well how about is there any FREE asp upload coding around the world is easy to use just like that one upload form and one asp form and one dll? <<

 
http://aspalliance.com/dundas/default.aspx
0
 
LVL 9

Author Comment

by:pcchiu
ID: 12128767
Yes the aspalliance.com/dundas/default.aspx look cool and let me read all the doc and see if I can change the filename somehow.

Thanks.
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 600 total points
ID: 12128796
Okay and good luck.

FtB
0
 
LVL 9

Author Comment

by:pcchiu
ID: 12128851
I've it installed and the sample was running great.   However I still can not figure out how to rename the file to the filename I want before it put to the server...  A little help will be great.  I increase the point to 150.   The only thing is I need the file under specific name before it get to the server or I don't mind to change it(automatically) after it get upload to the server.

Thanks.
0
 
LVL 9

Author Comment

by:pcchiu
ID: 12144086
OK I'm not that lazy.   I found the way to use the form to pass a value and insert it as a filename.   Thanks for the software FtB.

0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12144690
I am sorry to take so long to get back--I teach all day at the university on Tuesdays & Thursdays. I am happy that you have this resolved.

FtB
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question