How can I change the name of images to website URL when user save them (save image as) , like this site :
Simple Desktop Website
for example the name of the image is : man.png
but when user save that the name of image will change to mysite.com.png
This is just for your understanding
string _strName = "mysite.com.png";
System.Web.HttpResponse _response = System.Web.HttpContext.Current.Response;
_response.ClearContent();
_response.Clear();
_response.ContentType = "text/plain";
_response.AddHeader("Content-Disposition", "attachment; filename=" + _strName + ";");
_response.TransmitFile(Server.MapPath("Img\\zentree_1.png")); //location of your Image file
_response.Flush();
_response.End();
If that is not your expectation, then do reply with your code,
I believe i can help you on this.
Related
I tried to get the routeName from the URL because i need to set another class in the Layout of the body if i'm on the /Category page.
#{string classContent = Request.QueryString["routeName"] != "/Category" ? "container" : "";};
<div id="Content" class="body-wrapper #classContent">
My problem is, Request.QueryString["routeName"] is always empty and couldn't find why.
Does someone know why it's always empty or has a better approach for setting a different class if you're on a certain page?
In the end i solved it with that code:
var segments = Request.Url.AbsolutePath.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
string classContent = "container";
if (segments.Count() > 1) { classContent = segments[1] != "category" ? "" : "container";}
Request.Url.AbsolutePath gets the whole URL.
After that i split the whole URL and save it into a list.
Then i test if the list is long enough to be on another site except home.
In the end i look if the second part of the url is /Category and save the Css class appropriate to the output of the url.
Here I get all values from one html now i want append to another html page . how to i do?
$('.fa-cart-plus ').click(function () {
var images = $(this).attr('src');
var price = $(this).attr('data-name');
var con = $(this, '.modal-body>p').parent().html();
$('#tom').append("<div class='card' data-name=" + price + " > <button type='button' class='close' data-dismiss='modal'>×</button><img src=" + images + " ><div>" + con + "</div></div > ")
});
If I understood you correctly, there are two html files in your app and you want the content from first page to be available on the other when you redirect.
If so, you need to save your data as you'll lose your data when redirected. The best way will be to save the data to the backend database. However, if you do not have the database, you can use localStorage.
Try this:
// ......
var con = $(this, '.modal-body>p').parent().html();
var cards=[]; // Added code from here
cards.append("{your_content}"); //Replace `{your-content}` with your content
localStorage.setItem('cards', {cards});
Now at the other route, you can get data from it using:
const cards = localStorage.getItem('cards');
$("#tom").html(cards);
Refer: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
Hope it helps. Cheers!
This Request.JSON http://mootools.net/demos/?demo=Request.JSON using JSON data in a way like this,
var data = {"previews":[
{"Countrycode":"us", "src":"us.jpg", "description":"desc will be here"},
{"Countrycode":"uk", "src":"uk.jpg", "description":"desc will be here"},
]};
In the above method we use Countrycode & images by writing name of each image our self.
I'm looking for a method to use Geonames via http://api.geonames.org/export/geonamesData.js?username=orakzai to retrieve Countrycode and CountryFlags via http://www.geonames.org/flags/x/xx.gif where xx is 2 letter ISO country code
The flags are returned as GIF files instead of any sort of JSON. You would just use
<img id='myImage' src="http://www.geonames.org/flags/x/??.gif" />
But fill in the ?? with the country code that geonames uses.
You can put the tag in your page somewhere and use some javascript to change the URL to the one you have computed or you can figure the URL on your server and insert it as the HTML page is created.
If you want to do it in javascript, for example, in jQuery you would have something like this to change the URL on an already loaded image tag with id='myImage'
$("#myImage").attr('src', "http://www.geonames.org/flags/x/" + countryCode + ".gif")
Similar service, like geonames.org:
var country_code = 'uk',
img_uri = 'https://flagpedia.net/data/flags/normal/' + country_code + '.png';
I am using ASPPDF active x component. I have already create a pdf document from ASP. But the content of this pdf is only simple text. How I can convert asp variable, that contains html tags, to pdf document?
here is my code
Set Pdf = Server.CreateObject("Persits.Pdf")
Set Doc = Pdf.CreateDocument
Doc.Title = "Mi primer documento PDF"
Doc.Creator = "arsys.es"
Set Page = Doc.Pages.Add
Set Font = Doc.Fonts("Helvetica")
Params = "x=0; y=650; width=612; alignment=center; size=10"
Page.Canvas.DrawText "pdf text", Params, Font 'can I put asp variable instead of "pdf text"?
Filename = Doc.Save( Server.MapPath("salida\archivo.pdf"), False )
Response.Write "Enhorabuena! Descarga tu primer archivo PDF"
I have the same thing running on my server. The guide that comes with it requires you to use Doc.ImportFromUrl but that will need an full reference to the ASP page. So....
1) Create your ASP page and layout your page with SQL and bindings if required. I use this with a QueryString parameter as I only want to reference one value to create the PDF.....my example is based around creating an invoice.
2) In a "different folder" to your ASP page run the ASPPDF script in a page
3) Ensure you have a full reference to the path e.g. http://www.domain.com/file.asp
This should help:
<%
Set Pdf = Server.CreateObject("Persits.Pdf")
Set Doc = Pdf.CreateDocument
' A4 paper size - if US required remove/comment the line below.
Set Page = Doc.Pages.Add(595.3, 841.9)
Doc.ImportFromUrl "http://www.yourdomain.com/yourfile.asp?valueID=" & Request.QueryString("valueID")
Filename = Doc.Save( Server.MapPath("quotation.pdf"), False )
'Response.Write "Success! Download your PDF file here
%>
That works for me anyway!
I have an image uploaded to a server with location like : opt/glassfish/domains/domain1/applications/j2ee-modules/SmartbadgePortal/images/2badge.jpg
I am trying to read the contents of the image rather than the image information. I searched a lot and could get the following solution for it :
File uploadedFile = new File(path);
System.out.println("Uploaded File is *** : " + uploadedFile);
item.write(uploadedFile);
Image image = null;
image = ImageIO.read(uploadedFile);
System.out.println("Image Contents is *** : " + image);
However, the when I used System.out to print "image". I get :
Image Contents is * : BufferedImage#10d7a81: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace#722270 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 418 height = 387 #numDataElements 3 dataOff[0] = 2|#]
But , this is not what I need. I need the contents of the image and need to store it in a BLOB column in MySQL. Please help as I am been trying various methods like ByteArrayInputStream ,but every time I see only this info rather than image itself.
Although it's not the answer you're looking for, my recommendation is to store the image in your server's file system and saving the file name (and maybe directory) in your DB. Storing an image in a BLOB cell is usually not a good idea unless there's a specific reason.