Posted to tcl by Gerry at Sat Sep 15 20:03:02 GMT 2012view raw

  1. if {[set filename [tk_getOpenFile]] != {} } {
  2. db eval {create table if not exists main.blobs(filename text, time text default current_timestamp, content blob)}
  3. db transaction {
  4. db eval {insert into main.blobs(filename) values(:filename)}
  5. set rowid [db eval {select last_insert_rowid()}]
  6. set bloblength [file size $filename]
  7. db eval {update main.blobs set content = zeroblob(:bloblength) where rowid = :rowid}
  8. set infile [open $filename {RDONLY BINARY}]
  9. set blobchan [db incrblob main blobs content $rowid]
  10. puts -nonewline $blobchan [read $infile]
  11. flush $blobchan
  12. close $infile
  13. close $blobchan
  14. ::GEB::fillwins
  15. }
  16. }
  17.