mierlp Posted December 10, 2012 Posted December 10, 2012 Hi, Within my application i registrate employees, every employee has a unique nummer (something like 05432467). The employee needs to upload a copy (scan/image) from his ID card. The FileUpload is not the problem but i would like to upload only images so the employ may only see/filter image files. Because a scan can have any name i also would like to change the name when i upload it. So the images gets the name of the employee nummber, something like 05432467.jpg. To do this i need to extract thee extension because a image can be a .jpg, gif, tif etc. - How to create a filter when the user selects a file for thee upload - How to retrieve the extension from the uploaded file Regards Peter Quote
Administrators Farshad Mohajeri Posted December 11, 2012 Administrators Posted December 11, 2012 - How to create a filter when the user selects a file for thee upload As far as I know it is not possible. - How to retrieve the extension from the uploaded file See our Upload demo. Quote
Harry Rogers Posted December 11, 2012 Posted December 11, 2012 This may be useful ? Once you have the file on the server you can fairly easily check if the file header looks appropriate (PNG/BMP/JPG). e.g function IsJpegFile(const FileName: string): Boolean; const RightBuf: array[0..3] of Byte = ($FF, $D8, $FF, $D9); var Buf: array[0..3] of Byte; begin FillChar(Buf, 4, 0); with TFileStream.Create(FileName, 0) do begin Position := 0; ReadBuffer(Buf[0], 2); Position := Size - 2; ReadBuffer(Buf[2], 2); Free; end; Result := CompareMem(@RightBuf[0], @Buf[0], 4); end; function IsBmpFile(const FileName: string): Boolean; const RightBuf: array[0..1] of Byte = ($42, $4D); var Buf: array[0..1] of Byte; begin FillChar(Buf, 2, 0); with TFileStream.Create(FileName, 0) do begin Position := 0; ReadBuffer(Buf[0], 2); Free; end; Result := CompareMem(@RightBuf[0], @Buf[0], 2); end; function IsPngFile(const FileName: string): Boolean; const RightBuf: array[0..7] of Byte = ($89, $50 ,$4e, $47, $0d, $0a, $1a ,$0a); var Buf: array[0..7] of Byte; begin FillChar(Buf, 8, 0); with TFileStream.Create(FileName, 0) do begin Position := 0; ReadBuffer(Buf[0], 7); Free; end; Result := CompareMem(@RightBuf[0], @Buf[0], 7); end; [with a little help from here http://www.hidelphi.com/201004/check-a-picture-file-type-jpeg-or-bitmap-using-tfilestream/ and here http://www.fileformat.info/format/png/corion.htm] Quote
mierlp Posted December 12, 2012 Author Posted December 12, 2012 Hi Farshad/HarryG Thanks for the quick respons, i'm going to try the solution which HarryG posted Regards Peter Quote
Harry Rogers Posted December 12, 2012 Posted December 12, 2012 I'm currently doing something a bit similar and have been looking at some automatic face detection or recognition as an attempt to give some probability that the uploaded file does actually contain a useful image. The larger commercial SDKs are a bit expensive. These guys might be useful http://face-detection-recognition.com/ - anyone know how to write an interface to the C++ dll they have ? Cheers Quote
chefdackel Posted December 4, 2013 Posted December 4, 2013 As far as I know it is not possible. See our Upload demo. there is a "filter"-property in the UniGUI file upload components, but it does seem to have no effect on filtering file extensions for uploading. Are there any news how to set an extension filter with the standard UniGUI file upload component? Best Regards Quote
altagur Posted December 4, 2013 Posted December 4, 2013 hear exist examle how do dragdrop html5. I am done so And where in javascrip code handled event draon dragstart and drop On drop you can check fileextension and exist javascrip library understatndig kind of file - peg img gif and so on client browser side before sending to server. C-dll have interfece using image file/string and coordinates To use need export dll inteface by delphi dll export tools Will be created pascal wrapper such as MSoffise wrappers. Dll reaklli recognize faces but in additional need html5 webcam integration study, Quote
altagur Posted December 4, 2013 Posted December 4, 2013 I have two frame with grid and dragdrop files from desctop ajax In event onload of dragdrop html5 exaple you have file data and can use library for image detection. You can more image handling fore eaple image shadowing Javascript librarys for image type detection exists in sourceforge.ned and another places http://www.pixastic.com/lib/ Exist FaceRecognition Delphi libraries for example http://delphideep.blogspot.ru/2013/03/face-recognition-with-delphi.html Hear how to grap from webcab foto and upload to the base http://forums.unigui.com/index.php?/topic/3642-capturing-camera/ after need recognize by delphi recognition library. I do and its work. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.