mob/verb/Example()
var/a = input("Find a soundfile.") as sound
Problem description:
How would I go about determining the size of the chosen sound file?
Code:
mob/verb/Example() Problem description: How would I go about determining the size of the chosen sound file? |
Try using length(a) and probably use - http://www.byond.com/developer/Y2kEric/y2k_ByteConverter - to determine the size in MB etc
Just a note, you can't determine the size BEFORE downloading it for this to work the server will need to download the said file. I would use a JavaScript solution with World/Topic in the browser to determine the size Client side before sending it. |
In response to A.T.H.K
|
|
A.T.H.K wrote:
Try using length(a) and probably use - http://www.byond.com/developer/Y2kEric/y2k_ByteConverter - to determine the size in MB etc As Kaiochao pointed out, AllowUpload() gives you the size of the file before actually allowing it to be uploaded to the server. |
Anywho, whenever you ask a player to choose a file through "input() as file", the client.AllowUpload() event is called, giving you the name and size of the file. If you return false, the file is rejected. Check the ref for more info.