Index: openacs-4/packages/file-storage/www/file-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/file-add.tcl,v diff -u -r1.12.2.2 -r1.12.2.3 --- openacs-4/packages/file-storage/www/file-add.tcl 21 Jul 2005 18:44:41 -0000 1.12.2.2 +++ openacs-4/packages/file-storage/www/file-add.tcl 29 Jul 2005 02:27:02 -0000 1.12.2.3 @@ -13,6 +13,7 @@ content_body:optional {title ""} {lock_title_p 0} + {name ""} } -properties { folder_id:onevalue @@ -57,7 +58,7 @@ set context [fs_context_bar_list -final "[_ file-storage.Add_File]" $folder_id] } -ad_form -html { enctype multipart/form-data } -export { folder_id lock_title_p } -form { +ad_form -html { enctype multipart/form-data } -export { folder_id lock_title_p name } -form { file_id:key {upload_file:file {label \#file-storage.Upload_a_file\#} {html "size 30"}} } @@ -163,13 +164,14 @@ close $fd set upload_files [list $title] set upload_tmpfiles [list $tmp_filename] - } + } ns_log notice "file_add mime_type='${mime_type}'" set i 0 set number_upload_files [llength $upload_files] foreach upload_file $upload_files tmpfile $upload_tmpfiles { set this_file_id $file_id set this_title $title + set mime_type [cr_filename_to_mime_type -create -- $upload_file] # upload a new file # if the user choose upload from the folder view # and the file with the same name already exists @@ -179,6 +181,10 @@ set this_title $upload_file } + if {![empty_string_p $name]} { + set upload_file $name + } + set existing_item_id [fs::get_item_id -name $upload_file -folder_id $folder_id] if {![empty_string_p $existing_item_id]} { @@ -212,16 +218,20 @@ file delete $upload_file.tmpfile } -edit_data { + set filemame [template::util::file::get_property filename $upload_file] + if {[string equal $this_title ""]} { + set this_title $filename + } + fs::add_version \ - -name [template::util::file::get_property filename $upload_file] \ + -name $filename \ -tmp_filename [template::util::file::get_property tmp_filename $upload_file] \ -item_id $file_id \ -creation_user $user_id \ -creation_ip [ad_conn peeraddr] \ -title $title \ -description $description \ - -package_id $package_id \ - -mime_type $mime_type + -package_id $package_id } -after_submit {