Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upload word files on the web server and access them later

Status
Not open for further replies.
Apr 11, 2002
193
IN
Hi,

I want to upload doc files on the web server. These files are specific to a project that i will select from a combobox. I want to create a folder of the name of project if it doesnt exist, then upload the files in that folder. If the folder of the selected project already exist then i want to upload the files in that folder. If the file is already existing then i want to overrite it. I want to place a button to upload the files and at the upload postback i want to read all the name of the files and display them in a list box.

If i want i will select a file from the listbox and open it. Is this possible or is it too much of a asking.

Thanks,
Manish
 
Manish --

Part of the core upload routine you'll need can be found at thread855-841796.

For altering/creating directories/files you'll need to work with classes in the System.IO namespace.

The two main classes you'll need for folder manipulation and creation are the Directory/DirectoryInfo classes (for files it will be the File/FileInfo classes).

Try doing a search here (and also a search for "recommended ASP.NET" sites) -- and do a little background research on this. You should be able to find something on point.
 
Hi Isadore,

I have created a web form in which i have placed a file field html control. Made that control as run as server control. Then i have placed a button and named it as upload. I have written the following code in the click of the button

if(FileBrowse.PostedFile != null)
{
Textbox1.text = FileBrowse.PostedFile.FileName;
}

I get a error saying "Object reference not set to an instance of an object."
I did include FileBrowse = new HtmlInputFile(); before using the FileName but it still gives me the error. I want the file path of the selected file to be uploaded on the web server.

Any clue for which object i am getting this error.

Thanks,
Manish
 
Manish --

Being the weekend, most of the big guns are out -- I did see BoulderBum this morning (Sunday) for a bit -- can't say exactly what it is that is causing the error. Let's see if someone chimes in on Monday with a little more direction for you --
 
Hi,

I was able to create directories and load the word docs on my web server. I load the doc files in a listbox and there is open button that i have placed below the listbox to open the selected doc file. I have referenced the micorsoft word 9.0 library and am using the following code to open the selected doc file. But its giving me a access denied error not enough previleges for the aspnet user. The code is

if(lstDocs.SelectedIndex >= 0)
{
object missing = System.Reflection.Missing.Value;
object readOnly = false;
object isVisible = true;
object strWordPath = Server.MapPath("")+"\\"+prjName+"\\"+"Word"+"\\";
strWordPath = strWordPath+cmbType.SelectedItem.Text+"\\"+lstDocs.SelectedItem.ToString();
WordApp = new Word.ApplicationClass();
WordApp.Visible = true;
Word.Document wordDoc = WordApp.Documents.Open(ref strWordPath, ref missing,ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible);
}

In my machine on locahost also i am getting the same error. When i debug i get the error while creating the object of word.ApplicationClass(). If i get this correct then my module is complete. Hopping for some suggestions. Do i need to give any special previleges for the aspnet user for this to work.

Thanks,
Manish
 
Manish,
Think your error may be similar to one I was/am having when trying to work with OutLook calendar through ASP.Net and web server as I was getting error message at the same spot creating the OutLook object. Through research it appears that I need to have OutLook installed on the webserver because unless your security is different the ASPNet client can't see the drive that in my case OutLook is installed on. Yours may be similar but with word. Currently working with our network team to get them to install on web server so can test what I found. I will see if I can locate that article I read for you and post it if I do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top