Welcome Guest Search | Active Topics | Sign In | Register

Test for file type, audio length Options
Suraj11
Posted: Tuesday, May 19, 2009 10:02:21 AM
Rank: Member
Groups: Member

Joined: 5/12/2009
Posts: 10
Hello

I am using your Ajax uploader product to upload audio and image files via a web browser interface. I have several quick questions I hope you can clarify:

1. Do you have sample code to permit only the upload of several (ie, more than only one) file types? There are two scenarios:

(a) audio, where only wav, mp3 (and possibly aac) file types are permitted; and
(b) images, where only jpg, gif and png are permitted.

2. In the case of the audio file upload an additional ‘test’ is needed to compare the ‘duration’ of the audio to see if it is the correct ‘duration’ within a small tolerance. Therefore the question is – does your upload object have any ability to determine the ‘duration’ of common or specified audio file types and/or read the audio file header for ‘duration’?

I am hoping you do, but if not then I am thinking a crude workaround would be to test for file type, then apply a test to fit within deduced file length allowing for it to be either mono or stereo, and with an assumed bit depth and sample rate. Crude, but better than nothing.

Any ideas or suggestions would be very welcome.

Thanks,
Angel
eo_support
Posted: Tuesday, May 19, 2009 10:33:32 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You can set the uploader's AllowedExtension to filter the file type so that user won't be able to upload files that you do not want.

The uploader does not perform any kind of checking on the files, it does provide you the necessary support so that you can perform whatever kind of checking you would want though. You can handle the uploader's FileUploaded event and then perform any checking you wish to do there. If the file looks OK, then you can "take" it by adding your DB record, moving it to somewhere else; or if the file doesn't look OK, you would simply reject it by deleting it.

Your "crude" workaround works for wave file but may not work for mp3 or aac. Those are sophistically compressed files. When those files are compressed, there is a "target bit rate" setting but the actual bit rate varies. In order to precisely validate those files, you can take a look of DirectX filters. DirectX has a managed interface so it is not very difficult to use. Obviously those are far out the scope of the uploader so it is not able to include such functionalities.

On the other hand, wave file is very simple. You can find plenty of source code on the Internet to read the wave file header to get the sample rate, format, etc.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.