Solved

When i upload the file in server

Posted on 2008-10-29
3
170 Views
Last Modified: 2013-11-21
When i upload the document file in local machine is working fine but the same code is not working in server. any idea?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test</title>
</head>
<body>
<form name="frmTest" method="post" action="" >
<input type="file" id="txtUpload" name="txtUpload" />
<input type="submit" />
<%
dim ObjFSO
Set ObjFSO = Server.CreateObject("Scripting.FileSystemObject")  ' create Object
if not ObjFSO.FolderExists("C:\xxx") then  'check , if  Folder does exist yet
   ObjFSO.CreateFolder("C:\xxx") ' create new folder   
else
   response.write("C:\xxx already exists!")
end if
 
if(request.Form("txtUpload")<>"") then    
    'Getting the server path
    path="C:\xxx"
    'Getting the selected file    
    filename=request.Form("txtUpload")       
    'if the file is doc    
    if(objFSO.GetExtensionName(filename)="doc") then        
        objFSO.CopyFile filename,path & "\100.doc"                                        
    end if
end if
 
%> 
</form>
</body>
</html>

Open in new window

0
Comment
Question by:roisroy
[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
3 Comments
 
LVL 12

Accepted Solution

by:
techExtreme earned 250 total points
ID: 22830005
Hello,
Yes because you are using explicit location (i.e. C drive  and a folder inside it etc...)

In reality when you host a solution, you are given say 1-10 gb space, but you cannot assume it is going to be c drive only, it can be D:, E: or F:.

So you must use relative path to store your files or atleast use server.mappath in order to get the actual path of where exactly your folder is and then you can add your filepath in there.

Also, It will always work on your local machine, because ideally you can access any drive, path on it which won't be the same when uploaded to a host.
Hope it helped.
Let me know of any issues.

0
 
LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 250 total points
ID: 22833252
You have to use Server.MapPath method to get the current path dynamically,

ref.
http://www.plus2net.com/asp-tutorial/mappath.php
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do you configure load balancing for AD FS (SSO)? 17 107
SQL to update characters in table column 6 163
Problem to App source 6 95
how to share a file to edit with dropbox? 3 42
Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
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, f…

696 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