MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

File Upload is working only in server not in client mach

  Asked By: Scottie    Date: Sep 11    Category: MOSS    Views: 2216

Let me explain you clearly! its funny.
I have two systems:
1) server (MOSS)
2) my local machine
I developed a web part in server which uploads a file into a custom lists.
It checks whether the file exists in the system
-- if exists, it allows to add it to a custom list
-- if not exists, it will show a message "File Not Exists"
its working fine in the server.
But when i am uploading a file in my local machine it is showing the message
"File Not Exists"
I copied the path of a file from server and I opened my web part page in my
local machine, and pasted the file path in the web part and uploaded.
Surprisingly, it uploaded the file successfully. That means it is checking the
file only in the server, not from the local machine. Why it is doing like this?
I need to get files from local machine from which the web part page is
Can any one help me. Thanks in advance...
fileStream.Read(contents, 0, (
spAttachmentCollection.Add(fileName, contents);
lblError.Text =
}(FileUpload1.Value != string.Empty)
if(File.Exists(FileUpload1.Value)) FileStreamfileStream =
File.OpenRead(FileUpload1.Value); stringfileName =
fileStream.Name.Substring(3); byte[] contents =
SPAttachmentCollectionspAttachmentCollection = newItem.Attachments;"Issue Raised
Successfully!"; else {
lblError.Text =
}"File Not Exists!";



4 Answers Found

Answer #1    Answered By: Deana Lowery     Answered On: Sep 11

The web part code always runs on the server. I recommend using the HTML
tag <input type=file> tag to allow the site visitor to select the file
to upload.

For an example, please refer to my Image upload  Web part.

Answer #2    Answered By: Felecia Goff     Answered On: Sep 11

I didnt get you. How to run the code with elevated previlages.
My code is right or wrong? Why it is checking the file  in server  when uploading
a file from client  machine? Please help me to solve this problem.

Answer #3    Answered By: David Scott     Answered On: Sep 11

SharePoint Object Model code only runs on the server. Only JavaScript or
VBscript runs on the client. You wrote code using the object model. Since it
runs on the server  it looks to the local machine for the file  upload.

Answer #4    Answered By: Lakeshia Gould     Answered On: Sep 11

Now, i came to know the problem, but still i
am wondering for solution. Is there any way to upload  a file  from client  to
server ?

Didn't find what you were looking for? Find more on File Upload is working only in server not in client mach Or get search suggestion and latest updates.