Solved

HELP ASP coding problem.

Posted on 2004-09-22
12
521 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

816 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

10 Experts available now in Live!

Get 1:1 Help Now