Pls Help me in ASP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sha407
    New Member
    • Aug 2006
    • 9

    Pls Help me in ASP

    i am doing now asp project,,,,,,,h ow to save *.doc file in database or in folder
    pls help me

    Shan
  • ilaiyaraja
    New Member
    • Jul 2006
    • 6

    #2
    Originally posted by sha407
    i am doing now asp project,,,,,,,h ow to save *.doc file in database or in folder
    pls help me

    Shan
    hi

    U first upload that .Doc into one Folder
    then u save the file name in ur database with file path.

    Comment

    • lipsa
      New Member
      • Aug 2006
      • 35

      #3
      '***INCLUDE UR CONNECTION FILES HERE like
      '**<!--#include file="dbconnect _sql.asp" -->

      <%
      '******code for uploading file and storing in a folder(here new_folder) starts here**

      Set objFileUpload = Server.CreateOb ject("ur_fileUp loadComponent.F ileUpload")
      dim CompleteFileNam e, FileName, UserFileName, SysFileName, UserFileExt
      'here we assign values to the variable
      FileName = objFileUpload.F ilePath("file1" )'***file1 ,u will get frm ur form
      CompleteFileNam e = FileName
      OnlyFileName = Mid(FileName,le n(FileName)-InStr(1,StrReve rse(FileName)," \")+2)
      UserFileName = Mid(FileName,1, inStr(1,FileNam e,".")-1)
      UserFileExt = Mid(FileName,Le n(FileName)-2,Len(FileName) )
      'here we check if the folder(where we want to upload the file)exists,if not,again create it
      set FS = server.CreateOb ject("Scripting .FileSystemObje ct")

      if fs.FolderExists (server.MapPath ("new_upload")) =false then
      fs.CreateFolder (server.MapPath ("new_upload "))
      End If
      UploadedFileNam e = Server.MapPath( ".") & "\" & "new_upload "& "\" & OnlyFileName
      objFileUpload.u pload "file1", UploadedFileNam e


      'code for uploading file and storing in a folder(here new_folder) ends here

      %>

      <%
      '**code for inserting the file name into database starts here
      dim strConn
      dim strSql
      Set oConn = Server.CreateOb ject("ADODB.Con nection")
      Set oRs = Server.CreateOb ject("ADODB.Rec ordset")

      strSql= "insert into <my_file_tabl e>[(FILE_NAME_COLU MN)] values ('" & UploadedFileNam e & "')"

      oRS.open strSql,conn
      '**********NOW CLOSE THE CONNECTION N RECORDSET HERE
      **code for inserting the file name into database ends here

      %>
      NOW FINETUNE THE CODE AS PER UR REQUIREMENT N GET GOING :)
      REGARDS,
      Lipsa

      Comment

      • jay_dev
        New Member
        • Jul 2006
        • 10

        #4
        are you creating the file or does it already exist?
        because if you were creating it there is a much easier way

        Comment

        • sha407
          New Member
          • Aug 2006
          • 9

          #5
          Originally posted by jay_dev
          are you creating the file or does it already exist?
          because if you were creating it there is a much easier way

          i want to create a new file........... if alredy exit that file display the message in browser how to create it?????????????

          Comment

          Working...