currently I am trying to make an <a> tag that will download an xml from a link and I also want that file renamed. I know <a download="test.xml" href="http://www.somesite.com/anothertest.xml"> is supposed to be used to create this effect but the file name remains "anothertest.xml" rather than changing to "test.xml" whenever I download it any ideas on what is causing this?
Browsers don't allow the use of the download attribute to rename a file when the file is from an external server/domain.
Related
As I have searched, making a download link is like
<a href="image_url.png" download>download</a>
But the image must be in project directory. How to download from another server?
For example if I want to download django logo the code is supposed to be:
<a href="https://www.djangoproject.com/s/img/logo-django.42234b631760.svg" download>download</a>
but that's not working (it opens and shows the image in the current tab instead of downloading), but any file in my own server is being downloaded easily. What is the best way to do that? tnx
You simply need to put name of the file (how it should be saved) in download. Like this:
download
Edit:
Actually I was wrong. You can find the answer here. If you want to download SVG in regular way, like any other file, you need to use JavaScript, not just plain HTML tags. Or you can download it as PNG, but as I assume: that's not the point.
Sorry for mistake.
you put link in href on anchor tag:
download
here's what I have so far but it downloads aff.php and then stops because there is no file in my FTP.
<button>Download</button>
One thing you could do, is remove the first href (href="https://www.abcgameservers.com/aff.php?aff=47") and replace it with onclick="window.open('https://www.abcgameservers.com/aff.php?aff=47')". That way you could have it open the page and download the file.
I have a small question on how to add a folder that can be downloaded from my website. Would I call the file like how I normally call everything else (pictures, videos) and just make an:
<a href="LOCATION-OF-MY-FOLDER"</a> and the browser will automatically give the option of downloading? Or is there another actual process?
You can't download folders without linking them, but what you can do is create some type of compressed file (.zip, .rar. 7z) and put the folder inside of it. and make it
<a href="LOCATION-OF-MY-FOLDER.zip">
My Folder
</a>
I don't think you can create a link to download the directory without creating a zipfile of that directory and making that available to download.
Yes it's possible. However, it is not just for a folder, but for a file type. There are two solutions were provided in answer to this Stack Overflow question. Try out the top two ranked answers.
I am trying to download one csv file in my html file with anchor tag. Its getting downloaded only as .txt file. Tried few things like download attribute but nothing working.
Please help
<a href="https://xxxxxxxxxxxxx/20140815-111929455-000001-00030-1658.csv?__gda__=1440109223_83f5e968923d7f99b30844358fe4ce4c" download="temp.csv" type="text/csv" target="_blank"/>
What about removing the file name from the download attribute and adding it to your href attribute? Doing it that way should eliminate the need for a target and type as well.
<a href="/path/temp.csv" download>link</a>
I haven't tried this with a csv file before, but it's worked for me with images after checking out a w3schools example.
I have some PDF's sitting in a folder on my computer, is there a way to write a link to open them on to a webpage?
The main idea is when the site goes live the link will be used to download the pdfs from the folder, but obviously at a later stage the folder will be a temp folder on my website.
So at the moment i just want to open the pdfs from a link, and the final goal will be to have the links download them.
Can any one help me?
This is the file path to get to the pdf i want to link to.
C:\Users\Shaun\Documents\FormValue\CS1.pdf
How would i create the link?
If you want to have a link to a PDF, you just have to put the relative path to the file in the href attribute of an a tag. So let's say you had a folder called pdfs, with the file boom.pdf inside it, and folder called site sitting beside it, with the file site.html in it. Then all you'd have to do is put this link in the html file:
Link to a pdf
In most (all?) browsers now a days, that will open the PDF in a new tab. To download it you would right-click it and do the Save Link As thing. Just need to get the path in href right.
UPDATE
If you want to use the full path to the file, you need to prefix it with file://. Then you just put it in the href the same as with a regular link, ending up with something like:
Link to a pdf
This should work with your set up, but if the pdf and the html files are stored near each other, relative URLs are still a good option. A little bit of Google work should show you how to write those.
For each PDF just do what I talk about here.
<object height="950" data="sample-report.pdf" type="application/pdf" width="860">
<p>It appears you don't have a PDF plugin for this browser.
No biggie... you can <a href="sample-report.pdf">click here to
download the PDF file.</a>
</p>
</object>
It works with most browsers and it degrades nicely.
It sounds like youre asking if you can put a link on a web site to a PDF sitting on your computer. You can't. The files have to be either on another web site or on your site's server.
If you are using ASP.NET, you can have the link point to a handler that accepts a query string identifying the file, either by file name or a hash of the file. Then the handler can look in the folder for a file that matches the pattern, read the file as a byte array, and then write those bytes to HttpResponse.