You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
After migrating to v2, the file upload stopped working. I then went through the docs and copied the exact same code as in the Single File Upload Doc example, and the validation keeps failing on the server side. I don't know how to solve this if even the example from the official superform docs doesn't work..
here are the versions of the dependencies i am using in my stack:
schema & server side
// NOTE: Import fail from Superforms, not from @sveltejs/kit!
import { superValidate, fail, message } from 'sveltekit-superforms';
import { zod } from 'sveltekit-superforms/adapters';
import { z } from 'zod';
const schema = z.object({
image: z
.instanceof(File, { message: 'Please upload a file.'})
.refine((f) => f.size < 100_000, 'Max 100 kB upload size.')
});
export const load = async () => {
return {
form: await superValidate(zod(schema))
}
};
export const actions = {
default: async ({ request }) => {
const form = await superValidate(request, zod(schema));
if (!form.valid) {
return fail(400, { form });
}
// TODO: Do something with the image
console.log(form.data.image);
return message(form, 'You have uploaded a valid file!');
}
};
Description
After migrating to v2, the file upload stopped working. I then went through the docs and copied the exact same code as in the Single File Upload Doc example, and the validation keeps failing on the server side. I don't know how to solve this if even the example from the official superform docs doesn't work..
here are the versions of the dependencies i am using in my stack:
schema & server side
frontend:
The text was updated successfully, but these errors were encountered: