Comments (6)
You need to make a normal, non-Inertia request to download files. All Inertia requests must return a valid Inertia response, which a file download of course isn't. So, instead of using an <inertia-link>
, just use a regular <a>
. ๐
from inertia-laravel.
but can't post a form with an <A>
tag
like <Link href="/download" method="post" as="button" type="button">download</Link>
from inertia-laravel.
You can use this in onClick
fetch(route('documents.download', { id: document.id }))
.then((res) => res.blob())
.then((blob) => {
const file = window.URL.createObjectURL(blob)
window.location.assign(file)
})
from inertia-laravel.
You should be able to just use a regular form. Optionally with the target set to _blank
to ensure a new window/tab opens and your Inertia app will just keep running.
<form action={yourDownloadUrl} method="post" target="_blank">
<button>Download</button>
</form>
from inertia-laravel.
You can do it with a form... but remember the csrf
token.
First, send the token to the Inertia view where you are going to insert the form:
return inertia ( 'YourView', [ 'token' => csrf_token() ] );
Now, in the view, insert the csrf token in a hidden input.
For instance, in a React view:
<form action = { route ('your.named.route', your.param) } method = "post">
<input type="hidden" name="_token" value={props.token}/>
<button>Download</button>
</form>
from inertia-laravel.
gular
<a>
.
Did you find a way around this?
I need to send a post request to download the file.
from inertia-laravel.
Related Issues (20)
- Data management on the Client Side
- Show toast or message after request complete. HOT 2
- Cant get validation working on laravel-inertia-vue HOT 2
- Login not working with Laravel + Inertia + React HOT 1
- problem in running ssr when using vue vite and ziggy
- Add dinamic parameters to Inertia::lazyLoad props HOT 1
- SSR with Dynamically Shared Props HOT 1
- Providing empty object to the view
- Add config option to ignore paths with SSR server HOT 1
- Progress bar not working on route navigation HOT 1
- Laravel / Vue 3 Install Issues HOT 1
- Inertia with Laravel + SSR + pm2 HOT 1
- Laravel Inertia Form Validation Issue
- Safari can not handle redirect()->back() HOT 1
- Router events runs multiple times. HOT 5
- JSON response error on subdomains - Firefox HOT 1
- Inertia with supervisor SSR error HOT 1
- SSR (react) error ui doesn't match initial ui when including prop having html
- โจFeature Request: Support `ziggy` 2.0 HOT 4
- fails testing nested pros
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inertia-laravel.