Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 15th, 2004, 12:11 AM
Friend of Wrox
Points: 1,288, Level: 14
Points: 1,288, Level: 14 Points: 1,288, Level: 14 Points: 1,288, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Stockholm, Sweden
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default Delete Files

Hi Dears I have to solve a problem which is
In my web pages a user come and enters his data which include his picture as wel which is uploaded and store on my server. But the problem is that when admin or he himself remove from my website then his data which is in data base is deleted but his picture is still on the server.
How can I delete this picture from the server ?

(*_*)

Numan
--------------------------------------------------
It is not important what you get But important is how you got it
__________________
(*_*)

Numan
--------------------------------------------------
It is not important what you get But important is  how you got it
Reply With Quote
  #2 (permalink)  
Old October 15th, 2004, 12:59 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

You are storing the image in a directory. Isn't it ? let the relative path of that folder be \uploads (in relation to the folder of the page which deletes the user). You must store the file name in database. Let the filename of file corresponding to a person be pic_00213.jpg.

You can then delete this file using following script in your delete file. This uses file system object.

dim objFSO
Set objFSO=Server.CreateObject("scripting.filesystemob ject")
If(objFSO.FileExists(Server.MapPath(".") & "\uploads\pic_00213.jpg") then
    objFSO.DeleteFile Server.MapPath(".") & "\uploads\pic_00213.jpg"
End If
set objFSO=nothing
Reply With Quote
  #3 (permalink)  
Old October 15th, 2004, 01:11 AM
Friend of Wrox
Points: 1,288, Level: 14
Points: 1,288, Level: 14 Points: 1,288, Level: 14 Points: 1,288, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Stockholm, Sweden
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

Dear if I should store these files in data base then please guide me that how can I store them in a data base and show them on front end



(*_*)

Numan
--------------------------------------------------
It is not important what you get But important is how you got it
Reply With Quote
  #4 (permalink)  
Old October 15th, 2004, 01:26 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

You do not need to store the file in database. Actually the above code assumes that you are not storing it in database.

You need only store the name of the file in database. Store the file in a folder at server. This you can do with any standard file upload component like ASPUpload etc.
Reply With Quote
  #5 (permalink)  
Old October 15th, 2004, 01:28 AM
Friend of Wrox
Points: 1,288, Level: 14
Points: 1,288, Level: 14 Points: 1,288, Level: 14 Points: 1,288, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Stockholm, Sweden
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

No dear if I want to store a picture in databse then how can I do this ?



(*_*)

Numan
--------------------------------------------------
It is not important what you get But important is how you got it
Reply With Quote
  #6 (permalink)  
Old October 15th, 2004, 04:50 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Here is a sample script. The table name is TBLFILESTORAGE. The upload component used is ASPUpload.

'getting uploaded files
            dim obj_upload
            Set obj_upload = Server.CreateObject("Persits.Upload.1")
            obj_upload.OverwriteFiles = true
            dim i_count ' the number of files uploaded
            i_count = obj_upload.Save(Server.MapPath(".") & "\uploadedfiles")
            if(i_count<1) then
                Response.Write("No file is uploaded or the uploaded file is empty.")
            end if

            'saving files to db
            dim i_loop
            dim rst_file_storage
            dim obj_file
            For i_loop = 1 to i_count
                'add file to db
                Set obj_file = obj_upload.Files(i_loop)
                dim file_content
                file_content = obj_file.Binary
                If Not obj_file Is Nothing Then ' If file is not enpty
                    Set rst_file_storage = Server.CreateObject("adodb.recordset")
                    rst_file_storage.Open "SELECT * FROM TBLFILESTORAGE", cnn_sql_blob, 2, 3
                    rst_file_storage.AddNew
                    rst_file_storage("file_name").Value = obj_file.Name
                    rst_file_storage("file_size").Value = obj_file.Size
                    rst_file_storage("file_content_type").Value = obj_file.ContentType
                    rst_file_storage("file_content").Value = obj_file.Binary
                    rst_file_storage.Update
                    rst_file_storage.close
                    set rst_file_storage = nothing
                    Response.Write("Successfully stored " & cstr(i_count) & " file(s) in DB.")
                else
                    Response.Write("The file was not selected or it was empty")
                end if
            next
----------------------------------------------------------

The field file_storage is of type image.

The above is for SQL 2000.

Here is the script to create db table.

qry_createtable="CREATE TABLE [TBLFILESTORAGE]("&_
        "[file_id] INT IDENTITY,"&_
        "[file_name] VARCHAR(250),"&_
        "[file_content_type] VARCHAR(1000),"&_
        "[file_size] INT,"&_
        "[file_content] IMAGE)"
cnn_sql_blob.Execute qry_createtable
Reply With Quote
  #7 (permalink)  
Old October 18th, 2004, 03:13 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by qazi_nomi
 No dear if I want to store a picture in databse then how can I do this ?



(*_*)

Numan
--------------------------------------------------
It is not important what you get But important is how you got it
Here you go.
http://stardeveloper.com/articles/di...1033101&page=1.
This is a nice article to insert images in database but however downloading files/images from database who are more than 4mb is a problem.
;)
Reply With Quote
  #8 (permalink)  
Old October 18th, 2004, 06:55 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

iniro

Images and files are not stored in datastores in fact I do not believe its possible. If it is you will loose portability, bak files will get huge and....(lots of reasons why not)

madhukp's comment is very clear:
;;;You need only store the name of the file in database. Store the file in a folder at server. This you can do with any standard file upload component like ASPUpload etc.

In addition:
;;;This is a nice article to insert images in database but however downloading files/images from database who are more than 4mb is a problem.

Any image meant for a web page that is 4mb is crazy talk, the ASP upload object will handle a 4mb file without a problem (You should set the max size you want to allow though)



Wind is your friend
Matt
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete cache files quickly Maxxim BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 September 4th, 2007 09:07 AM
How Can I Delete Cookie files. MICZ VB How-To 4 August 18th, 2007 04:56 AM
delete files in the server miguel.ossa Classic ASP Basics 1 September 5th, 2005 12:15 PM
Delete files on closing browser spacy ASP.NET 1.x and 2.0 Application Design 7 September 8th, 2004 04:24 PM
How Can I Delete Cookie files. MICZ Pro VB 6 2 August 13th, 2004 10:44 AM



All times are GMT -4. The time now is 05:55 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.