![](https://cdn.discordapp.com/avatars/282364620839190539/a_117cddb1d3ee4972990c63eecf5331b8.gif)
const uploadPage = () => {
const [file, setFile] = useState<File | null>(null);
const handleFileChange = (e:any) => {
setFile(e.target.files[0]);
console.log(file)
};
const handleSubmit = async (e:any) => {
if (file) {
const response = await appwriteFunctions.uploadFile(file);
console.log(response);
}
}
return (
<>
<span className="font-bold text-4xl">Controls</span>
<div className="flex flex-col items-end justify-end gap-4">
<Label htmlFor="picture" className="text-xl">Upload ISO</Label>
<form onSubmit={handleSubmit} className="w-full flex items-end justify-end">
<Input
onChange={handleFileChange}
id="file"
type="file"
ref="file"
value="Reset"
className="w-[19%] border-none h-fit px-5 py-3 text-md outline-dashed outline-1 hover:outline-yellow-100"
/>
<Button type="submit" className="text-white px-4 py-2 rounded">
Upload File
</Button>
{file && <p className="text-sm mt-2">File selected: {file.name}</p>}
</form>
</div>
</>
![](https://cdn.discordapp.com/avatars/186656408450629633/a_1020a50ae94486c09c02e2868564778d.gif)
instead of handleing file change and form submit can this all not be done in the form submission?
![](https://cdn.discordapp.com/avatars/282364620839190539/a_117cddb1d3ee4972990c63eecf5331b8.gif)
i guess i'll try
![](https://cdn.discordapp.com/avatars/186656408450629633/a_1020a50ae94486c09c02e2868564778d.gif)
What error message are you getting?
![](https://cdn.discordapp.com/avatars/282364620839190539/a_117cddb1d3ee4972990c63eecf5331b8.gif)
it just returns null
![](https://cdn.discordapp.com/avatars/186656408450629633/a_1020a50ae94486c09c02e2868564778d.gif)
if you wrap it in a try catch does it throw anything?
![](https://cdn.discordapp.com/avatars/282364620839190539/a_117cddb1d3ee4972990c63eecf5331b8.gif)
nope. I can't even check whether it got the file or not.
![](https://cdn.discordapp.com/avatars/282364620839190539/a_117cddb1d3ee4972990c63eecf5331b8.gif)
its just returning "undefined"
![](https://cdn.discordapp.com/avatars/462046107556511744/504fd808296728e8e89d82b8ea1e77a9.webp)
What's returning undefined?
![](https://cdn.discordapp.com/avatars/282364620839190539/a_117cddb1d3ee4972990c63eecf5331b8.gif)
handleFileChange, first step that im doing is making sure its printing on which file was selected
![](https://cdn.discordapp.com/avatars/462046107556511744/504fd808296728e8e89d82b8ea1e77a9.webp)
Would you please make sure a file is being passed to setFile
? Then, make sure file is set in handleSubmit
![](https://cdn.discordapp.com/avatars/282364620839190539/a_117cddb1d3ee4972990c63eecf5331b8.gif)
was calling it wrong, managed to fix it 😅
So the handleSubmit is giving an error. I did follow the docs on how to create a createFile
![](https://cdn.discordapp.com/avatars/282364620839190539/a_117cddb1d3ee4972990c63eecf5331b8.gif)
even tried manually putting my bucket ID instead
![](https://cdn.discordapp.com/avatars/462046107556511744/504fd808296728e8e89d82b8ea1e77a9.webp)
What are the permissions on the bucket?
![](https://cdn.discordapp.com/avatars/282364620839190539/a_117cddb1d3ee4972990c63eecf5331b8.gif)
This actually did it, though it wasn't the permission. I was scrolling down and saw the extensions of files had specific set of files to take which prevented it from uploading 🙏
Recommended threads
- How to implement Google Authentication a...
Hi, I implemented Appwrite Google Authentication in NextJS v14.1.3 and successfully implemented the sign in feature (on SSR) when trying it in localhost, but wh...
- Running updateEmail results in user_targ...
Hello everyone! I'm running the following as part of my app (Flutter), so on the client side: ```const result = await account.updateEmail( 'email@example...
- Bandwidth increasing doubts
Hello , I don't want to disturb you , I just want to get my answers , My question is , I am not using any functions or storage , just using db and users auth ,...
![](/images/bgs/pre-footer.png)