Page 1 of 1

Saving a video file to mysql database..

Posted: Wed Apr 11, 2012 3:15 am
by shire
Hello,

Does anyone tried saving a video file in mysql database?

I tried using this code:

Code: Select all

              file$ = OpenFileRequester("Choose a file", "", pattern$, 0)
              
              If ReadFile(0, file$)
                length = Lof(0)
                *filereadbuffer = AllocateMemory(length)
                ReadData(0,*filereadbuffer,length)                
                
                filename$ = GetFilePart(file$) 
                If file$<>"" 
                  now$ = FormatDate("%yyyy%mm%dd",Date())    
                  SetDatabaseBlob(0, 0, *filereadbuffer, Length)
                 DatabaseUpdate(0, "INSERT INTO file (control, file, filesize, filename) VALUES ("+"'"+controlnum+"',?, "+"'"+Str(Length)+"', "+"'"+filename$+"')")
                   Else
                 MessageRequester("Warning","Can't save record!",#MB_ICONEXCLAMATION)
                EndIf  
              Else
                MessageRequester("Error","Couldn't read file!", #MB_ICONERROR)
              EndIf
but it doesn't save video files although it saves other files.

Any idea? please help..

Thank you in advance:)

Re: Saving a video file to mysql database..

Posted: Wed Apr 11, 2012 9:58 am
by kinglestat
its same as sending a blob. I had to stop using the PB libraries due to bugs when inserting large data....I would recomend using the mysql DLL lib directly. Look for libmysql_fr.pbi then add the functions you need

Re: Saving a video file to mysql database..

Posted: Tue Apr 17, 2012 9:06 am
by shire
@kinglestat:

thank you your reply..

but I still can't make it work..

Re: Saving a video file to mysql database..

Posted: Tue Apr 17, 2012 9:38 am
by captain_skank
I gave up with storing files in mysql.

I just store the location and filename of the file in the database now, cuts out any confusion :)