Solved

HELP ASP coding problem.

Posted on 2004-09-22
12
527 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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/…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

628 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