how to get author from file when upload using upload control using javascript

function CheckSchemaFileExistence() 

{

var Schemafilename=document.getElementById('<%= this.flUploadB.ClientID %>').value;

if(Schemafilename.length>0)

{

return true;

}

else

{

alert("File Name cannot be empty");

return false;

}

}

 

we written code in button click . i need a file author name . how to find it can any tell me .

thanks in advance

0
harish448
5/20/2008 8:10:34 AM
📁 asp.net.client-side
📃 24353 articles.
⭐ 1 followers.

💬 1 Replies
👁️‍🗨️ 852 Views

Hi harish448

For your information, I know you want to get the file's author name, which from client-side

But I think Not all type of files have the attribute of "author name" (I think only office file like .doc .xls have)

if you want to get a .doc file's author name, I suggest you to use OWC

The following code show how to get a doc file's author name and subject, Hope this helps:

    Word.Application oWord;
            Word._Document oDoc;
            
object oMissing = Missing.Value;
            
object docBuiltInProps;

            
object Source = @"DocPath";
            
object Unknown =Type.Missing;
            oWord 
= new Word.Application();
            
            
try
            
{
                oDoc 
= oWord.Documents.Open(ref Source,ref Unknown, 
                    
ref Unknown,ref Unknown,ref Unknown, 
                    
ref Unknown,ref Unknown,ref Unknown, 
                    
ref Unknown,ref Unknown,ref Unknown, 
                    
ref Unknown );

                docBuiltInProps 
= oDoc.BuiltInDocumentProperties;
            
                Type typeDocBuiltInProps 
= docBuiltInProps.GetType();
            
            
                
//获取作者
                string index = "Author";
                
string propsValue;
                
                
object docAuthor = typeDocBuiltInProps.InvokeMember("Item"
                    BindingFlags.Default 
| 
                    BindingFlags.GetProperty, 
                    
null,docBuiltInProps, 
                    
new object[] {index} );
            
                Type typeDocAuthorProp 
= docAuthor.GetType();
                
                propsValue 
= typeDocAuthorProp.InvokeMember("Value"
                    BindingFlags.Default 
|
                    BindingFlags.GetProperty,
                    
null,docAuthor,
                    
new object[] {} ).ToString();
                
                MessageBox.Show( propsValue,
"Author" );

                
//获取主题
                index = "Subject";
                propsValue 
= "The Subject";
                
                
object docSubjectProp = typeDocBuiltInProps.InvokeMember("Item"
                    BindingFlags.Default 
| 
                    BindingFlags.GetProperty, 
                    
null,docBuiltInProps, 
                    
new object[] {index} );
            
                Type typeDocSubjectProp 
= docSubjectProp.GetType();
                
                propsValue 
= typeDocSubjectProp.InvokeMember("Value"
                    BindingFlags.Default 
|BindingFlags.GetProperty,
                    
null,docSubjectProp,
                    
new object[] {} ).ToString();
                
                MessageBox.Show( propsValue,
"Subject" );

            }

            
finally
            
{
                
//关闭word进程
                object save = false;
            
                oWord.Quit(
ref save,ref Unknown,ref Unknown);
            
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord);    
            }

Regards!

-- "Mark As Answer" If my reply helped you --
0
blodfox777
5/20/2008 8:31:54 AM