I am trying to make a good old multiple image upload from the frontend where the client can specify how many FileUpload controls he/she wants (max 10 though)
So far it seems to work, but when the number of FileUpload controls gets over five it crashes when hitting the save button. This is my UI:
"Opret" is the save button ;)
My code for adding the FileUpload controls:
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (Session["noOfUploads"] != null)
{
int amountOfControls = Convert.ToInt32(Session["noOfUploads"]);
for (int i = 0; i < amountOfControls; i++)
{
FileUpload fUl = new FileUpload();
Label lblLineBreak = new Label();
lblLineBreak.Text = "<br />";
fUl.ID = i.ToString();
fUl.Visible = true;
pnlUploadControls.Controls.Add(fUl);
pnlUploadControls.Controls.Add(lblLineBreak);
}
}
And this is where I save the images on the save button click event:
List<Media> images = new List<Media>();
foreach (Control ctrl in pnlUploadControls.Controls)
{
if (ctrl is FileUpload)
{
FileUpload newFileUpload = (FileUpload)ctrl;
Media media = UmbracoSave(newFileUpload, storydDoc.Id);
if (media != null)
{
images.Add(media);
}
}
}
if (images.Count > 0)
{
storydDoc.getProperty("forsidebillede").Value = images[0].getProperty("umbracoFile").Value;
string xml = "<MultiNodeTreePicker>";
foreach (Media img in images)
{
xml += "<nodeId>" + img.Id + "</nodeId>";
}
xml += "</MultiNodeTreePicker>";
storydDoc.getProperty("billeder").Value = xml;
}
The id of the uploaded image is added to uComponents MultiNodeTreePicker as a XML value.
So basically when the number of FileUpload controls is greater than five it crashes with the dreaded: "Server Error in '/' Application. Runtime Error" message, which kinda leads me to a side-question:
How do you go about debugging usercontrols on a live site? If that is possible at all? I feel I have to guess what the error is everytime I develop a .net usercontrol. I have watched Niels' video about debugging and Attach to Process, but it doesn't work for me - not even on a local project :/ So how do you go about debugging your usercontrols?
Locally I tend to use the attach to process technique to connect to the worker process for my given website which allows you to use breakpoints and step throughs etc.
On the live server though, I tend to go back to old school, either writing variables out to the screen, or better, to the Umbraco log table.
Would be interested to know if folks are doing anything differently myself.
Yes, I've found myself debugging the old fashioned way by writing variables, response.redirect and so on ;) While it sort of works, it would be nice to be able to do some more "tracking"
Anyway, the multiple file/image upload: I skipped the approach from my original post and tried using the jQuery Multiple File Upload 'framework', but it still crashes :( Even when trying to upload a single image. This is my code:
.. and I'm having a hard time tracing where the problem is. In google chrome the taskbar says "Uploading(x%) ... " but when it's done uploading, it crashes.
Anyone got any experience working with the HttpFileCollection class to upload files to Umbraco?
I can't say I can see anything glaringly wrong with your code. Are there any more specific errors in your servers event log?
You are welcome to look through my code for uRest which is a set of web services for umbraco (currently unreleased) to see how I am handling uploading media files.
Crashing when uploading media and debugging
Hi all,
I am trying to make a good old multiple image upload from the frontend where the client can specify how many FileUpload controls he/she wants (max 10 though)
So far it seems to work, but when the number of FileUpload controls gets over five it crashes when hitting the save button. This is my UI:
"Opret" is the save button ;)
My code for adding the FileUpload controls:
And this is where I save the images on the save button click event:
The id of the uploaded image is added to uComponents MultiNodeTreePicker as a XML value.
So basically when the number of FileUpload controls is greater than five it crashes with the dreaded: "Server Error in '/' Application. Runtime Error" message, which kinda leads me to a side-question:
How do you go about debugging usercontrols on a live site? If that is possible at all? I feel I have to guess what the error is everytime I develop a .net usercontrol. I have watched Niels' video about debugging and Attach to Process, but it doesn't work for me - not even on a local project :/ So how do you go about debugging your usercontrols?
Any hint/help is greatly appreciated! :-)
All the best,
Bo
Hey Bo,
Locally I tend to use the attach to process technique to connect to the worker process for my given website which allows you to use breakpoints and step throughs etc.
On the live server though, I tend to go back to old school, either writing variables out to the screen, or better, to the Umbraco log table.
Would be interested to know if folks are doing anything differently myself.
Matt
Hi Matt,
Thanks for tuning in!
Yes, I've found myself debugging the old fashioned way by writing variables, response.redirect and so on ;) While it sort of works, it would be nice to be able to do some more "tracking"
Anyway, the multiple file/image upload: I skipped the approach from my original post and tried using the jQuery Multiple File Upload 'framework', but it still crashes :( Even when trying to upload a single image. This is my code:
.. and I'm having a hard time tracing where the problem is. In google chrome the taskbar says "Uploading(x%) ... " but when it's done uploading, it crashes.
Anyone got any experience working with the HttpFileCollection class to upload files to Umbraco?
Thanks again!
Bo
Hey Bo,
I can't say I can see anything glaringly wrong with your code. Are there any more specific errors in your servers event log?
You are welcome to look through my code for uRest which is a set of web services for umbraco (currently unreleased) to see how I am handling uploading media files.
http://urest4umb.codeplex.com/SourceControl/list/changesets
Matt
Hi Matt,
Thanks for your link :)
I got it to work last night by reading one of your old posts here: changing "umbracoExtensio" to "umbracoExtension" did the trick!
is working on a reply...