Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Questions about few problems with ASP script

Posted on 2004-08-16
6
Medium Priority
?
155 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
Independent Software Vendors: 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!

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

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

916 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