hello coder, could anybody can share an idea on making attachment files.

on my cms software. i wanted to have an attachment portion. where my doc,jpg,xls files can be attach. im planing to stored it on my app.path by copying the files. but my problem is when opening on the network computer. im also planning to save it on the database. but the big question is HOW? hmmmm..

sample code or little idea will be appreciated.


regard,
jaasaria

Recommended Answers

All 6 Replies

Make use of hyperlinks as is used in Office Word or Excel.

Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

'Under a label click event...

ShellExecute hwnd, "open", "file://c:\file.txt", vbNullString, vbNullString, conSwNormal

Has this solved your problem jaasaria? If so, please mark this as solved, found at the bottom of this page, thanks.:)

hi sorry for the late reply..

by the way thanks AndreRet for the reply.
your sample code really help me. but it doest not support my exact needs.

right now, temporary i stored by save file (doc,jpg,xls etc) to my app path. and open it using AndreRet code. but my problem is when im in the network computer and save some attachment file. it save to the workstation exe location.

my problem is, i want to save it in the database. or what ever flow. that i can manage easily my files. and have a secured stored location/drive.

right now, im open to anybody idea to cover up this problem.

thx for the follow up. ^_^

To save files to a network compute you will have to use the file system object in vb6.

Refer Microsoft scripting runtime in The project ->References. You will then use some code as below -

'Add the follwing to a module...
Public Sub fsoCopyFile(byval strSource as string,byval StrDest As string)

dim fso as new Scripting.FilesystemObject
Fso.copyFile StrSource,StrDest
end sub

' To call This Procedure in your form say under a command button 
fsocopyFile("D:\abc.txt","\\servername\Sharename\abc.txt")

If the destination folder is password protected then
refer to THIS post.

If a drive or folder is not shared, there is another way to do it...
You need to develop client & server based on TCP protocle.
server is installed on computer where file is local (which you want to copy)
and client may be used from any other computer.Client asks server to pass the file to him through TCP/IP and server completes his request...
See THIS link on how to achieve this.

http://www.freevbcode.com/ShowCode.asp?ID=988
I just got a sample code here.

By the way thx AndreRet for the reply.
Im thinking that to make a server connection first. where to save all my attachment file and transfer it the server folder.


^_^ thx and happy coding.....

No problem, it was a pleasure.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.