Simple ASP FileUpload implemntation?

This is an open forum for any mojoPortal topics that don't fall into the other categories.

This thread is closed to new posts. You must sign in to post in the forums.
7/17/2011 12:16:30 PM
Gravatar
Total Posts 92
Нет, я не изменил. До старости глубокой...

Simple ASP FileUpload implemntation?

Dears,

I believe this is the last issue in my project; I just want the user to upload his Resume to a folder he does not know!

 And I can not give him permission to see everything, so i searched all www in mojo to find a way how to do this and found no solutions.

I iam trying to use the ASP FileUpload controll but it always returns 0 for if (txtUpload.HasFile)...

Is that happen because this tag or I am missing something?

 enctype="multipart/form-data"

 

It must be easy ( http://msdn.microsoft.com/en-us/library/aa479405.aspx )

 

Please advice

and thank you

7/18/2011 6:25:40 AM
Gravatar
Total Posts 92
Нет, я не изменил. До старости глубокой...

Re: Simple ASP FileUpload implemntation?

Dears,

 

I just need to know if I missed something out of MS example or it is not applicable in MojoPortal because of the Form encryption type (post,multipart/form-data .. ) and if it is not applicable is there any suggestions?

I think many people need to make their users upload one file (resume for example) without giving them any extra permission, upload your picture or other staff, without even logging to the website !!

 

Please advice

7/18/2011 6:46:19 AM
Gravatar
Total Posts 18439

Re: Simple ASP FileUpload implemntation?

Hi Ghalib,

I recommend study the code for the Shared Files feature (mojoPortal.Features.UI/SharedFiles), it shows how to implement file uploads using NeatUpload. Shared Files feature also keeps the files secure by storing them on disk with a .config extension so the file cannot be requested by an http request even if the user could guess the location because .config files are protected by ASP.NET. So, only if the user is in an allowed role then we Response.WriteFile and change it back to its original name when allowed users download it.

NeatUpload can provide a progress bar for uploads if hosted in Full Trust but it doesn't work under Medium Trust so it must be disabled from Web.config, but in that case it degrades gracefully to normal file upload.

I'm not aware of anything in mojoPortal that would prevent typical upload implementations from working but I still recommend use NeatUpload since we have good working example code for it.

Hope that helps,

Joe

7/18/2011 7:15:41 AM
Gravatar
Total Posts 18439

Re: Simple ASP FileUpload implemntation?

Now that I think of it Shared Files uses the MuliFile NeatUpload to allow uploading multiple files at once. If you want to see example code for a single file, check the AdminProductEdit.aspx.cs in the WebStore.UI project.

Hope that helps,

Joe

7/18/2011 12:00:56 PM
Gravatar
Total Posts 92
Нет, я не изменил. До старости глубокой...

Re: Simple ASP FileUpload implemntation?

Thank you Joe,

I can not use NeatUpload because of my medium trust server, but If you are saying that typical uploadit will work then I will check my code again. It seems simple but I will double check. this is my first project at all on C# ..I was VB :)

Thank you again

7/18/2011 12:05:27 PM
Gravatar
Total Posts 18439

Re: Simple ASP FileUpload implemntation?

You can code it up using NeatUpload and if all references to NeatUpload are commented out in Web.config then it will work like normal upload and cause no errors in medium trust. Then if you ever move to full trust hosting you can easily enable it again from config and get the benefit of upload progress bar.

Best,

Joe

7/18/2011 12:39:48 PM
Gravatar
Total Posts 92
Нет, я не изменил. До старости глубокой...

Re: Simple ASP FileUpload implemntation?

Ok,

seems no problem in MojoPortal.

The problem was from using the FileUpload inside Ajax ModalPopupExtender which prevented HasFile from working correct.

 

Thank you

You must sign in to post in the forums. This thread is closed to new posts.