change upload-path dynamically

Last post 08-09-2005, 10:08 AM by Daniel Krebs. 2 replies.
Sort Posts: Previous Next
  •  08-08-2005, 12:02 PM 9350

    change upload-path dynamically

    Is there a possibility to change the upload-path dynamically?
     
    I would like to have for each recordset in my table one directory to upload.
     
     
  •  08-08-2005, 12:06 PM 9352 in reply to 9350

    Re: change upload-path dynamically

    Yes, below is an example:
     
    private void security_Changed(Object sender, EventArgs e)
            {
                string temp = "";
                switch(RadioList.SelectedItem.Value)
                {
                    case "Administrators":
                        Editor1.SecurityPolicyFile  = "Admin.config";
                        SetUploadsFolder("~/Uploads/");
                        break;
                    case "Members":
                        Editor1.SecurityPolicyFile  = "default.config";
                        SetUploadsFolder("~/Uploads/Member/");
                        break;
                    case "Guest":
                        Editor1.SecurityPolicyFile  = "Guest.config";
                        SetUploadsFolder("~/Uploads/Guest/");
                        break;
            //        case "Banned":
            //            Editor1.ReadOnly = true;
            //            break;
                    case "John":
                        Editor1.SecurityPolicyFile  = "Admin.config";
                        SetUploadsFolder("~/Uploads/Users/John/");
                        break;
                    case "Mary":
                        Editor1.SecurityPolicyFile  = "default.config";
                        SetUploadsFolder("~/Uploads/Users/Mary/");
                        break;
                    case "Tim":
                        Editor1.SecurityPolicyFile  = "default.config";
                        SetUploadsFolder("~/Uploads/Users/Tim/");
                        break;
                }
            }        
                        
            void SetUploadsFolder(string folder)
            {
                string phyfolder=Server.MapPath(folder);
                System.IO.Directory.CreateDirectory(phyfolder);
                
                //see security.config
                Editor1.Setting["security:ImageGalleryPath"]=
                Editor1.Setting["security:MediaGalleryPath"]=
                Editor1.Setting["security:FlashGalleryPath"]=
                Editor1.Setting["security:FilesGalleryPath"]=
                    folder;
            }
    
            </script>    

    You can find it in Personalization and Programmatic Security Example.
     
    Keep me posted.
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-09-2005, 10:08 AM 9396 in reply to 9352

    Re: change upload-path dynamically

    thanks, that works!
     
    Now a further question to this issue.
    If I press "insert Image" or "Insert xxx" I want to create the folder.
     
    But on those buttons is no postback,
    so I cannot do like I do with the "Save"-Button:
     
    Private Sub Editor2_PostBackCommand(ByVal Sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) Handles Editor2.PostBackCommand
     If String.Compare(e.CommandName, "Save", True) = 0 Then
         if ObjektLangbutton_insert.visible=true then 'Einfügen
       ObjektLang_Insert(ObjektLangbutton_Insert,nothing)
      end if
      if ObjektLangbutton_update.visible=true then 'Speichern
       ObjektLang_Update(ObjektLangbutton_Update,nothing)
      end if
     End If
    End Sub
     
    Can I add a postback for any button? If, how?
View as RSS news feed in XML