Update:
Images were saved in SQL server as blob type. Images get truncated if you do not check the option for blob in CF admin "Data sources" section..Option to check blob
It does not seem like CF is doing this. I see images truncated in Production that are just fine in Development.
I am using ColdFusion 11 in Development and Production. I can successfully upload images from my local dev with out any truncation. However, when I upload from the Production server, I am getting following error in FF, and the uploaded image is half of the original image:
"Image corrupt or truncated. URI in this note truncated due to
length."
This is my code I am using html form.
<cffile
action="upload"
filefield="IMAGE"
destination="#application.ImagePath#"
nameconflict="makeunique"
accept = "image/gif,image/jpeg,image/pjpeg,image/png,image/x-png,image/jpg"
/>
<cfimage name="uploadedImage"
source="#application.ImagePath#\#file.serverFile#" >
<cfimage source="#uploadedImage#" action="resize" width="1350"
height="590"
destination="#application.ImagePath#\#file.serverFile#"
overwrite="yes">
<cffile
action="readbinary"
file="#application.ImagePath##CFFILE.ServerFile#"
variable="binPhoto"
/>
<cffile
action="delete"
file="#application.ImagePath##CFFILE.ServerFile#"
/>
Related
I want to get image base64 from cahcedNetworkImageProvider widget without redownload it to share it in my App.
or if there's a way to share image as a URL and could be saved to the device in flutter
used flutter_cache_manager plugin to get cached data through this function
var file = await DefaultCacheManager().getSingleFile(url);
and works fine for cached images and if URL is new will download it then get back with file object
I have a web project and I have uploadedImage inside the web folder of the project. I want to load an image which is inside uploadedImage folder. Im deploying the war file in Tomcat server. I coded as follows
Upload a new Image
</div>
</div>
<%
String fname = (String) request.getAttribute("name");
String pathImage = "C://bimla//Dev//java//OCRSystem//WebContent//uploadedImage//";
System.out.print("uploaded image"+fname);
session.setAttribute("filename", fname);
fname = fname + ".jpg";
System.out.println("with extension"+fname);
String path = "";
if (request.getAttribute("name") != null) {
path = request.getAttribute("name").toString();
}
%>
<div class="row">
<div id = "display" class="col-lg-8 center-block modal-content">
<img src="C:\\bimla\\Dev\\java\\OCRSystem\\WebContent\\uploadedImage\<%=fname%>" width="600" height="400"/>
</div>
</div>
But image is not displayed. When copy paste the path in the browser image displays correctly. Do you have any idea?
Your page is loaded through http (I assume). Nowadays luckily there is quite some boundary that websites (e.g. everything coming in through http) can't address your local filesystem (e.g. URLs starting with file:/// or C:/)
On a related note, don't build a web application that allows to upload files right into the webapplication's folder. This is bad for
security
backup
updates
redeployment
Rather upload to some other location and include a download servlet.
Side note: you might need duplicate \\ to escape backslashes in various cases (HTML has no such limitations though), but you definitely only need single / if you choose to use slash as the directory separator (this is not your problem though)
Quick Fix: You should load the image through http. Assuming that the image is in the same web application as your JSP, using <img src="<%=request.getContextPath()%>/uploadImages/<%=fname%>"> (or similar - you don't provide enough information for a definitive statement) will load the image through http. Note that this only quickfixes your current problem. The proper fix will be to upload the images to a folder (or database or storage) outside of your web application's directory - for the reasons given above.
I am having an erratic problem using Azure blob storage where my images do not load consistently. The problem is that sometimes when I load a web page, the browser will not show the image, but if I refresh it will load correctly.
When the image doesn't load, the browser shows the default image placeholder. Here is an example:
If I check the hyperlink for the image placeholder, I find that it is the same as the when the image loads successfully, except the Shared Access Signature is different.
Sometimes the same image will fail to load for one link but load successfully for another link even in the same page and same page load. The only difference in the URL is the Shared Access Signature.
Here is my code to build the URL with the shared signature
// Get reference to blob (file) that is to be downloaded
blob = blobContainer.GetBlobReference(blobURL.ToString());
// Get shared access signature to download file from azure blob (valid upto "active duration" minutes) from now
signature = blob.GetSharedAccessSignature(new SharedAccessPolicy()
{
SharedAccessStartTime = null,
SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(60),
Permissions = SharedAccessPermissions.Read
});
// Append signature query string to blob / file that is to be downloaded
downloadURL = string.Format("{0}{1}", blob.Uri.AbsoluteUri, signature);
This is the final HTML image link on the web page, i.e. if I show source on the web page in the browser:
<img alt="Profile Picture" src="https://mystorageaccount2.blob.core.windows.net/abcdefg1-hi23-40b5-86de-a20b568f5626/1601/1234d664d1b74ce1aebf4403e5b74af7.jpg?se=2015-10-31T11%3A38%3A39Z&sr=b&sp=r&sig=SaiUToJg%5Ab3zcdef8EeOq84urHf6HQqS%2BAFt1dEQMNI%3D">
Has anyone else seen this problem? Any recommendations on what I might be doing wrong?
I suspect this could be related to the expiry period which you have set on your image blob's shared access signature (SAS). Is there any good reason where you need to set the SAS to 1 minute when you have set it's permission to read-only?
In my windows phone application, i'm using a webbrowser to render a HTML like this
private void webBrowserHTML_Loaded(object sender, RoutedEventArgs e)
{
WebBrowser web = sender as WebBrowser;
string description = web.DataContext.ToString();
web.NavigateToString(description);
}
My problem is i have html code that show an image in the variable description:
<img width=\"220\" class=\"logo\" alt=\"3950\" src=\"bandeau3950.png\" />
I put the image in the same folder with my code, but the image is not shown in the application.
Any solution please?
Solution 1
Use Base64 image uri format so that image is defined as part of html. You can use online conversion tools, like http://webcodertools.com/imagetobase64converter
Solution 2
Copy all required images to isolated storage folder. It can be done during app start up.
http://msdn.microsoft.com/en-us/library/ff431811%28VS.92%29.aspx
When html string is received save it to the same isolated storage as index.html
Do Navigate(new Uri("folder/index.html", UriKind.Relative))
In this case browser will be able to show images since your page and images in the same isolated storage folder.
Hi my application is MVC, have a view with windows media player, it plays on my local host but not on the hosting server, MIME is set up correct.
Here is my script:
<object codebase="http://www.apple.com/qtactivex/qtplugin.cab"
classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="application/x-oleobject">
<param name="url" value="../../Video/1.wmv"/>
<embed src="../../Video/1.wmv"
type="application/x-mplayer2"
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"></embed>
</object>
I tried same script in a simple HTML file, it worked well on the server.
I get 500 Internal Server Error (shown in Fiddler). Any suggestions.
Try using a helper:
<param name="url" value="#Url.Content("~/Video/1.wmv")" />
<embed src="#Url.Content("~/Video/1.wmv")"
This will ensure that a correct url to the video file is generated. In this example I suppose that you have a Video sub-directory and the file is inside this directory.
As far as the 500 error is concerned, I suppose it is not related to the code snippet you have shown. Try looking at the server's EventLog where unhandled exceptions are traced.