I have a web page that will display an image.
I created a folder within my website called 'photo' and uploaded that image to that folder using the following code:
string path = Server.MapPath(#"~/Photo/");
FileUpload1.SaveAs(path+FileUpload1.FileName);
I am using the following code but the image is not being displayed in the image control.
string path = Server.MapPath(#"~/Photo/");
Image1.ImageUrl = path + photoInfoObject.Photo;[photoInfoObject.Photo is a string of the name of the photo(eg: Penguins.jpg).]
still that image is not displaying.can anyone fix this?
Your code looks ok so this is probably a broken link to your image, for example you may be rendering an absolute path to /Photo/Penguins.jpg, whereas if you're using the build in Visual Studio Web Server with a virtual directory, the absolute path would be /Your Site Name/Photo/Penguins.jpg. So check the generated HTML to find out the path, and maybe use the "Net" panel inside the Firebug plugin for Firefox to easily see any 404 errors as the page loads.
Related
I am using ckeditor/ckfinder in my application to update the xml files content. While the update of xml content is working fine in this project, the browse server functionality is not working.
When I click on the browse server functionality it only display empty page.
Tried to set the baseurl and baseDir attribute for the image file but still it is giving the same blank screen.
What can be the reason behind this?
You need to tell you ckeditor where to find ckfinder for the browsing capabilities :
Try something like that:
CKFinder.setupCKEditor();
It looks for CKEditor instances to set it up your current loaded CKFinder
I've got some of problems with ckeditor, with mvc.net.
Not sure, you use it or using asp.net.
I give you code i use, and it's running, now :
var editor = CKEDITOR.replace('html_content_editor');
CKFinder.setupCKEditor(editor, '/Scripts/ckfinder/');
where html_content_editor is the id of my html text control
and '/Scripts/ckfinder' is the url of the content of all files and directories use for ckfinder.
And pay attention about setting in web.config.
In app.setting node, you have to use :
<add key="CKEditor.Directory.Path" value="D:\Tmps\Documents\" />
A simple issue but unable to find a solution.
I have some image files that I placed in a subfolder called icons in my working directory in my ASP.NET website. I want to set an image during initialization to the markers on my Google map. But this isn't working. I have tried-
var marker= new google.maps.Marker({icon:'E:\cdeez\Sites\googletest 5\icons\busballon.png', position:pos,map:map});
It gives an error:
Not allowed to load local resource: file:///E:/cdeezSitesgoogletest%205icons%08usballon.png
However there is no problem if I place the image in the working directory. I guess giving the absolute path is not the right way too. So what is the right way in the above case.(Just a reminder- the above code will be in the aspx file).
According to the MarkerOptions docs, the icon should be a URL. However local files (embedded with file:///) tend to be ignored by browsers if the website is served over http - and I think that is what is happening in your case.
I would suggest to try out the following steps:
try using a relative path, e.g icon: "/icons/busballon.png"
try using a http path to your file, e.g. icon: "http://yoursite.com/icons/busballon.png"
I am writing a web page to show image (image is dynamically generate by .Net charting) in a web. I have used the asp.net web forms URL routing to navigate to this page. Once I use the URL routing the image appear on the page. Anyway this is working fine for normal page browse.
More than likely your link to the image is using a relative path, and once you introduce routing you are working with a URL structure that appears to be deeper nested in the folder structure than it is.
When linking to the image for display I would recommend using root relative path something like /Images/MyFile.jpg rather than ../Images/MyFile.jpg, or similar.
This way if your route changes, and additional "folders" appear in the route, the link will still work.
I am trying to display an image from "C:\temp". Here's the code:
string root = "C:\temp\";
string[] files = Directory.GetFiles(root);
foreach (string f in files)
{
if (Path.GetFileName(f).Contains(user.WorkEmail))
{
img1.ImageUrl = root + Path.GetFileName(f);
}
}
If an image is not found, I get a thumbnail with a red "X" - fine, as expected.
If an image is found, I get a thumbnail but no image gets loaded/displayed. When I right click the thumbnail and go 'Properties' it shows the correct filename.
You need to make this image part of the web site in order to display it properly. You need to use a relative URL:
img1.ImageUrl = '/App_Data/foo.jpg';
The image file cannot be located anywhere, when it is part of the web site a separate request is made to the server to fetch the image which is served by IIS. If you want to use image files located in a folder outside of your site root you will need to write a generic handler which will read the image contents, stream it to the response with correct content-type and then point the ImageUrl to this handler.
looks like you're creating strings of the form "C:\temp\myfile.jpg", right?
That's not a valid URL. your address needs to be either relative to your website's root (e.g. /content/myfile.jpg) or else it needs to include the protocol (e.g. file://c:\temp\myfile.jpg for local files or http://mysite.com/content/myfile.jpg for web access)
i had that problem and solved it ...
you should give the image adres cut
e.g:
www.yoursite.com/folder/image.jpg
Your image source should be = "folder/image.jpd"
No need of root or website.
I am developing a website that has product images on an external server. I have code that tests to see if the image exists like (pseudo code):
DynamicString = FunctionThatCreatesDynamicString()
' DynamicString = "http://external_server/path/to/file1.jpg"
If ImageExists(DyanmicString) = StatusCode.200 Then
' Embed link in ASP.NET page
Else
' Embed not found image in ASP.NET page
End If
My code builds fine and appears to execute. The problem occurs when I attempt to view the external link in a browser, the image appears properly (I have to authenticate first, but that's OK considering I'm on an internal network and this app will be used internally).
However, when I attempt the view the source in my generated HTML page, I am seeing the image to the "Not Found" image when I know the image is there.
I compared all the characters in my dynamically assembled to the external link and all the characters are matching up correctly.
I'm wondering if the authentication has anything to do with why the image is not rendering properly on my rendered HTML.
Any thoughts?
It turns out the problem was the authentication to the images. I tried and was able to use a completely different approach. But thanks for the tip tangurena.