Solved

Questions about few problems with ASP script

Posted on 2004-08-16
6
148 Views
Last Modified: 2010-04-06

I have created a script that uploads a file. When it is uploaded, the filename gets stored in the database. It all works locally. However, when I put the script and database on the remote server. It doesn't seem to upload. Moreover, my form validations says that the file doesn't exist. The path where the files get stored localed is stated with a path of "c:\file\upload." The same folders are set with on the server too. I have even given iuser permissions to read/write...  Any ideas why doesn't work. I'm thinking it's the path of the folder. Maybe, it can't find the folder.

Another question, the script can't seem to retrieve the information from the database. It retrieves the data from another database which isn't even pointing to it on the script. Does anyone know why this is happening? It works locally. But when I up the script and database to a remote server, this happens. It  can't seem to find the database where I set it.
0
Comment
Question by:onL0oker
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:joeposter649
ID: 11816500
Are you using server.mappath to reference your upload and mdb files?
0
 

Author Comment

by:onL0oker
ID: 11816951

This is my script that uploads a file with conditions set. I'm not server mapping the path. Am I suppose to use server.map?

      <%
      Set Upload = Server.CreateObject("Persits.Upload.1")
      
      uploaddir = "c:\files\upload\"
      Upload.OverwriteFiles = False
      Upload.SaveToMemory

      Upload.Save(uploaddir)
      
      'checks for word document files, will reject if anything else
    For Each File in Upload.Files
      Filename = File.ExtractFilename
    Ext = UCase(Right(File.Path, 3))
      Size = File.Size

    If Not(Ext = "DOC") Then
            Response.write ("<script language=""javascript"">")                    'Better to user Javascript
            Response.write ("{alert(""Please submit Microsoft Word documents (*.doc) only!"")}")
            Response.write "javascript:history.back();"
            Response.write ("</script>")
      Else
            File.Copy("c:\files\upload\") & Filename ' & Session("directory") & "\"
            Session("wdstoryURL") = Filename
      End If
      
      Next
%>

The database is pretty much called through a include file which contains the dsn. I'm not server.mapping the mdb either. How do I map the mdb through the include file and also how do I server map the path for the upload script? How would I implement it base on what I have? Thanks.
0
 

Author Comment

by:onL0oker
ID: 11817022

Let me clear up the remote server. It is not exactly remote. It's pretty much a network. On my local machine, it works fine. Users could upload, and vew the retrieve information from the database perfectly.

But when I copy the files over the network to another computer. The database has also been setup for the script as well on that computer. It doesn't work. The script states the actual path of the directory where the upload files suppose to go. Do I really need to server map the path? Shouldn't it work because the script resides where the database and the actual path is at?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 15

Expert Comment

by:joeposter649
ID: 11817191
shouldn't this
File.Copy("c:\files\upload\") & Filename
be
File.Copy("c:\files\upload\" & Filename)
0
 

Accepted Solution

by:
TimRay15 earned 125 total points
ID: 11833085
A couple of points here - the ASPUpload method SaveToMemory has now been superceeded by calling Save with no path parameter i.e. in your case:
Upload.Save
(assuming you're not using version 2 in which case you are correct!)

Also, according my own use of ASPUpload, the File.Copy statement shouldn't have any brackets at all!

On a more general note, the example code in the user manual on the ASPUpload site (http://www.aspupload.com/manual_memory.html) would suggest that hard-coded directories are fine, and in fact I'm using (to borrow your object name) Upload.SaveVirtual("images/") to write to a virtual directory without needing Server.MapPath at all.  You might find the following code from the above manual page helpful as well:


Set Upload = Server.CreateObject("Persits.Upload")
' we use memory uploads, so we must limit file size
Upload.SetMaxSize 100000, True

' Save to memory. Path parameter is omitted
Upload.Save

' Access subdirectory specified by user
subdir = Upload.Form("subdir")

' Build path string
Path = "c:\upload\" & subdir

' Create path, ignore "already exists" error
Upload.CreateDirectory Path, True

' Save files to it. Our form has only one file item
' but this code is generic.
For Each File in Upload.Files
   File.SaveAs Path & "\" & File.FileName
   Response.Write "File saved as " & File.Path & "<BR>"
Next


There are a number of useful examples in the other manual pages as well, so I would suggest having a look and seeing which most closely matches what you need.

As for writing to the wrong database, have you checked that the dsn is set up properly on the server? (a favourite mistake of mine...)
0
 

Author Comment

by:onL0oker
ID: 11833469

I have already figured out the problem. Thanks.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

707 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

17 Experts available now in Live!

Get 1:1 Help Now