i've update a website from 4.5.2 to 4.9 and am now struggling with the new FileSystemProviders concept.
In the old version i hooked up to the Media.AfterSave event to allow the editor to optionally upload files to the folder "uploads" (which resides physically on the same level as the "media" folder). This is based on the media type that is chosen:
if (!string.IsNullOrEmpty(fileprop.Value.ToString())) { //get its path string path = fileprop.Value.ToString();
//does it use the standard path? if (path.Contains("/" + fileprop.Id.ToString() + "/")) { string newDirectory = "/uploads/"; string newPath = newDirectory + sender.Text + "." + extensionprop.Value.ToString();
//copy the old file to the new location System.IO.File.Copy(HttpContext.Current.Server.MapPath(fileprop.Value.ToString()), HttpContext.Current.Server.MapPath(newPath), true);
//delete the old file System.IO.File.Delete(HttpContext.Current.Server.MapPath(fileprop.Value.ToString()));
//set the file property to the new friendly path fileprop.Value = newPath; } } } }
The upload still works, but the path to the file in the Media section in Umbraco always gets prefixed with "/media/" (e.g. "/media/uploads/example.pdf" instead of "/uploads/example.pdf").
I guess it's caused by the "virtualRoot" parameter in the FileSystemProviders.config
How can i achieve a correct path in the Media section?
...ended up in injecting some jQuery in editmedia.aspx to adjust the filepath. Fast and easy solution. Thanks to Lee Kelleher for inspiration and code snippet on github.
Media.AfterSave and FileSystemProviders
Hi,
i've update a website from 4.5.2 to 4.9 and am now struggling with the new FileSystemProviders concept.
In the old version i hooked up to the Media.AfterSave event to allow the editor to optionally upload files to the folder "uploads" (which resides physically on the same level as the "media" folder). This is based on the media type that is chosen:
The upload still works, but the path to the file in the Media section in Umbraco always gets prefixed with "/media/" (e.g. "/media/uploads/example.pdf" instead of "/uploads/example.pdf").
I guess it's caused by the "virtualRoot" parameter in the FileSystemProviders.config
How can i achieve a correct path in the Media section?
Thanks!
Matthias
...ended up in injecting some jQuery in editmedia.aspx to adjust the filepath. Fast and easy solution. Thanks to Lee Kelleher for inspiration and code snippet on github.
How can I do that if the new folder is not in the same server?
e.g.: server in which I have umbraco: http://www.myserver.com
server in which I wanna store all media: http://static.myserver.com
how can I do that?
thanks!
is working on a reply...