Welcome Guest, Not a member yet? Register   Sign In
Uploaded filename length
#1

[eluser]Kemik[/eluser]
Hello,

A member of CI Base pointed out that they were having a problem downloading their code and deleting it. I discovered that the problem is the sql field length isn't long enough for their filename so I went to change it but they wondered, what if someone uploads something that's got a file name longer than 255 characters?

My question is, how can I validate the length of a filename before uploading it? Is it just the same as any other input field? I cannot just do a max_length because the local file location could exceed the 255 characters while the filename itself doesn't.

Any ideas?

Thanks.
#2

[eluser]adamp1[/eluser]
Why not just rename the zip file to use an id instead? Then you won't have the issue of having file names longer than 255 chars.
#3

[eluser]Kemik[/eluser]
You mean encrypt_name? It would be a way that would work but then users who download several code don't know which is which. Is there anyway to rename the file before uploading? I could shorten the name and add a code_id to the end of the filename so there isn't clashes.
#4

[eluser]xwero[/eluser]
You could rename the file with the id in your db for example and store the filename in a text type field and when downloaded you restore the user given name.
#5

[eluser]Alexandros Monastiriotis[/eluser]
Hi

I think you cannot validate the length of the filename in the client side, on a file type input tag.

You may have already thought about this but why don't you alter the field to TEXT in the database table;
#6

[eluser]Kemik[/eluser]
[quote author="Alexandros Monastiriotis" date="1208680396"]Hi

I think you cannot validate the length of the filename in the client side, on a file type input tag.

You may have already thought about this but why don't you alter the field to TEXT in the database table;[/quote]

Because there's no point in storing really really long file names.

I'm going to try and find a way to change the encrypted name to the filename submitted before the user downloads.




Theme © iAndrew 2016 - Forum software by © MyBB