SlickUpload
Welcome Guest Search | Active Topics | Log In | Register

Save file info to database Options
imsam67
#1 Posted : Tuesday, November 22, 2011 10:18:18 PM
Rank: Member

Groups: Registered

Joined: 11/22/2011
Posts: 17
Location: Florida

I'm planning to use the uploader in an ASP.NET MVC 3 app.

I understand that the uploader uses UploadSession as its model. One of the things I want to do upon successful upload is to save the filename and its location information in a database and be able to associate it with a project.

Two questions:

  1. Is there a code sample that I can use that would show me how to take some action -- preferrably on server side -- after successful file upload?
  2. How can I pass some parameter to slick uploader e.g. pass ProjectId which I will need in associating the file with a project?

Thanks,
Sam


Thanks,
Sam
Axosoft
#2 Posted : Wednesday, November 23, 2011 10:11:28 AM
Rank: Administration


Groups: Administrators

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

Have you taken a look at the Quickstart example? You should be able to set up SlickUpload to post back to your controller action method, run through all uploaded files in the controller action method, and do the database insert there. Pass up the ProjectId with an @Html.Hidden inside the form.

Or are you trying to do an operation after each file is uploaded, rather than when the whole batch is complete? This is possible, but it means that you'll also have to add more code to remove the records if the file is removed by the user, or the upload is cancelled or errored.

If I'm totally missing the point of your application, can you give me more details on the flow you're envisioning?

imsam67
#3 Posted : Friday, November 25, 2011 11:46:23 AM
Rank: Member

Groups: Registered

Joined: 11/22/2011
Posts: 17
Location: Florida

I'm not trying to handle an operation after each file. I can handle all of them all at once. I do however want to rename files before they're saved by appending a timestamp at the end of their names i.e. myFile.jpg becomes myFile_20111125114458.jpg.

Also I want to use SlickUploader in a partial view -- I've already emailed you my partial view -- and be able to pass a parameter or two while loading up the partial view i.e. @Html.Partial("~/Views/MyFileUploadView.cshtml", new Krystalware.SlickUpload.UploadSession { myId = Model.MyId, mySecondId = Model.SecondId })

Once the files are uploaded -- to Amazon S3 --, I want to save their names and pointers in my database. This way, I can show my users a list of files that are associated with the IDs I had passed by reading file names/URLs from the database.

For example: Let's say I passed a ProjectId as a parameter to SlickUploader. I will then associate uploaded files with this ProjectId in my database so that next time a user pulls up the project view in my MVC 3 app, they'll see all the files uploaded for that project. Because I have file names and URLs in my database, I can easily create hyperlinks to their location on S3 for my users to download them.


Thanks,
Sam
Axosoft
#4 Posted : Monday, November 28, 2011 10:41:47 AM
Rank: Administration


Groups: Administrators

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

You shouldn't need to use UploadSession as the model for your partial view. I'd use whatever model has the data values you need. Then use @Html.Hidden's inside the form to pass them up. SlickUpload will include them when it does its final completion postback, and they'll be accessible from your action method code there so that you can hook everything up in the database.

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.