Solved

HELP ASP coding problem.

Posted on 2004-09-22
12
518 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
  • 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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 150 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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 information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now