I want to create a page where I can upload pictures and at the same time bring them to the page.
for example: I have a picture controller which has Index, addpictures in View.
Could anyone please help me?
I am a beginner, so it would be great if you'd write as simple as possible.
Thanks in advance.
You may take a look at the following blog post for a tutorial about uploading files in ASP.NET MVC.
The Path class is defined in the System.IO namespace so you will have to bring that into scope.
If you want to be able to show the uploaded file you will have to store it in some other folder than the App_Data. Files are not directly accessible by clients from this folder. You could for example use the Content folder instead. Once you get the file appear in this folder on the server you could reference it from the view using the <img> tag: <img src="#Url.Content("~/content/someimage.jpg")" /> where you could pass the name of the file to the view from the upload action.
Related
hi I am new in codeigniter. I have welcome.php file. so please tell me that how I can create more files like about us.
I created about_us.php in views and aboutus.php in application/controllers/aboutus.php
I am accessing file with this url localhost/restaurent_templatescodeg/index.php/about_us
but 404 Page Not Found message display.
Please help
Copy welcome.php to about_us.php and change the name of the class to About_Us. Make a view (just php and/or html output) in the views folder and load it via the controller.
For sample I got these two modules.
Module.Admin
Module.Web
Then, all images that are uploaded inside the Module.Admin is place inside it, sitemap goes like this.
Module.Admin
- Content
-- Uploads
--- Images
Now, how can I load as source these images inside the Module.Web > View .cshtml file?
As I've notice, these two modules are having two different ports. I hope you understand what I'm saying. Feel free to ask. Thank you
Sounds like you made the module a web project too? That means that they will run in seperate sites and not be able to share information.
You should probably use plugins instead. I've described how you can do it in my blog: http://blog.gauffin.org/2012/05/griffin-mvccontrib-the-plugin-system/
If you only want to access files you have to setup a custom VirtualPathProvider which can access the files from the other library.
How do I access resources in a .Net Web Project. I created a web project and then in App_LocalResources folder added a resx file "AstroWap.resx". Now how do I access values from that. The property My.Resources itself is not available.
Good reference reading to use resource files here
To create an access properties - right click your solution, select properties then click the link to create a resource file. You should see a excel type grid. Type your key value pairs in there.
To access it should be
<Namespace>.Properties.Resources.<ResourceName>
The issue is probably how you have added the resource. It might have circumvented the auto generated code which gives you the above syntax
You can check if it has added the auto gen code by looking in your web project under properties -> resources.resx -> resource.cs.designer. The designer file is the autogenerated file and you can see the access code for the underlying resx file. This assumes you have used the default resx file as above. See image for example in solution explorer
In addition this SO question does give more options for accessing resx files if you have some project constraints. I appreciate not everyone can do the above due to team work practices etc.. It's just what I do. And it does work.
Use following code for it:
<%=GetLocalResourceObject("labelname")%>
in aspx page.
If your page name is Test.aspx then your resource file must have name as Test.aspx.resx, otherwise you can not access the resource file value.
I'm working on an ASP.NET web application for our corporate intranet users. I have a form where a user should provide a path to the file on the local network (something like "\localServer\someFolder\someFile.ext") without uploading the actual file. The issue is that users don't want to type the whole file path and want to use some kind of visual browse dialog.
The standard HTML <input type=file> element allows to browse for a file, but most of the browsers (except for IE) don't allow to access file's full path, so I think it should be done by some external component like Silverlight, Flash, Java applet etc.
I tried to do it with Silverlight, but I'm getting a SecurityException when trying to access file's full path using Silverlight's OpenFileDialog class.
This java applet http://jumploader.com/demo_images.html seems to do something similar to what I'm looking for, but it's focused on uploading files - I only need to be able to get file's full path and pass it to the server as a string.
Any suggestions would be appreciated.
Telerik ASP.NET AJAX RadFileExplorer has the functionality you're looking for:
http://www.telerik.com/products/aspnet-ajax/fileexplorer.aspx
You can use their Custom File Content Provider to hook the GUI to your server's file system.
http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/server-sideapi/dbfilebrowsercontentprovider/defaultcs.aspx
This should be possible with Flash's uploading capabilities. SWFUpload has an API that you may be able to access from JavaScript to extract the selected file name without actually uploading anything. See docs here, for example getFile():
getFile is used to retrieve a File Object from the queue. The file retrieved by passing in a file id (the id property from a file object) or a file index (the index property from a file object).
So, I've created my wonderful winforms app that I want to unleash upon the world, and now I am trying to create a simple website to host some basic information and link to the setup file (msi installer file )....
I have a button on the asp.net page and the setup file setupApp.msi in same folder as the asp.net page. I am currently trying the following:
Response.Redirect("http://./SetupApp.msi");
But this best guess at what to do is not working. Is there something wrong with Mime types here? What do I need to put in the click event to allow users to download this file?
The path you are passing in to the method is not valid (there's no server name called ".").
You can pass in a relative path and it should work fine because ASP.NET will resolve the path:
Response.Redirect("SetupApp.msi")
Or if it's not in the same folder, try one of these:
Response.Redirect("../Downloads/SetupApp.msi")
Response.Redirect("~/SomeFolder/SetupApp.msi")
Keep in mind that you don't necessarily have to do the whole redirect at all. Instead of writing code in an ASPX file you could just have a link to your MSI:
Download my app!