nuno_couto Posted June 18, 2006 at 11:32 PM Report Share #33693 Posted June 18, 2006 at 11:32 PM Boas. Num formulário html que envia um ficheiro para um script PHP para que seja guardado no servidor, sei que é possível limitar o tamanho do ficheiro no script, mas, para verificar esse tamanho, o ficheiro já foi enviado, sobrecarregando desnecessáriamente o servidor, e fazendo o utilizador esperar durante o tempo do upload. Penso que com um java script será possível limitar o tamanho do ficheiro logo no formulário. Alguem sabe ajudar? Obrigado. portalmundial.net »» criamos sites Link to comment Share on other sites More sharing options...
Guest id194 Posted June 19, 2006 at 12:55 AM Report Share #33712 Posted June 19, 2006 at 12:55 AM Não, isso não será possível: The browser security does not allow the scripts (Javascript/VBScript) or even applets and ActiveX Controls to read files from the local hard disk. You can only read files if your code is signed by some Certificate Authority (CA). Now the input type "FILE" also does not have the permission to read files. We cannot do anything about that since thats what HTML says. So since it cannot read files, it cannot find the size of the file with which the input tag is associated. Since it cannot find the file size, there is no function exposed by JavaScript/VBScript to return the file size. But if you need to find the file size, say in order to restrict the size of the file uploaded to your web-server. Then you can do so by counting the file contents on the server-side, once the user submits it to the server. Thats what many of the free e-mail providers like www.hotmail.com do. Link to comment Share on other sites More sharing options...
skin Posted June 19, 2006 at 09:31 PM Report Share #33806 Posted June 19, 2006 at 09:31 PM eu penso que tens mesmo de usar esta chave: <input type='hidden' name='MAX_FILE_SIZE' value='100000000'> e penso so ser possivel em .php porque esta chave eu uso para PHP 😉 Our lives begin to end the day we become silent about things that matter - Martin Luther King Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now