forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Binfile problem

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
X-Tools
Valued Contributor
Valued Contributor


Joined: 20 Sep 2001
Posts: 296
Location: Germany

PostPosted: Mon Feb 10, 2003 11:16 am    Post subject: Binfile problem Reply with quote

Hi,

i have a problem using binfile.
I am developing a tool (for a customer) which uploads a document
into a mysql database.
Because the max. lenght of a mysql string and the mysql server configuration i found a great way to split the document and put it together into the data field.

Upload works great, but download does not.
If i get the whole binary file in a local variable the data seems to be ok. But BINFILE WRITE seems to write other data ?! (what should i say)

Here is a snippet of my code:
Upload:

Code:

   %%filesize = @file(@dlgtext(localpath),Z)
   
   BINFILE OPEN,1,@dlgtext(localpath),READ
    binfile seek,1,0
     %%bincounter = 0
    DIALOG SHOW,uploadprogress
   repeat
     BINFILE SEEK,1,%%bincounter
     if @not(@binfile(EOF,1))
       %%data = @binfile(READ,1,BINARY,5000)
      if @zero(%%bincounter)
        mysql query,UPDATE documents SET documents_document = '%%data' WHERE documents_id = '%%id'
      else
          mysql query,UPDATE documents SET documents_document = CONCAT(documents_document","'%%data') WHERE documents_id = '%%id'
       end
     end
     %%bincounter = @fadd(%%bincounter,5000)
     DIALOG SET,uploadprogress,@format(@fmul(@fdiv(%%bincounter,%%filesize),100),5.0)
   until @binfile(EOF,1)   

    mysql query,UPDATE documents SET documents_filename = '@name(@dlgtext(localpath)).@ext(@dlgtext(localpath))' "," documents_filesize = '%%filesize' WHERE documents_id = '%%id'
   DIALOG HIDE,uploadprogress
   BINFILE CLOSE,1


And Download: (I tried different ways - adding directly to binfile and saving into variable first)

Code:

   mysql query,select documents_filesize FROM documents WHERE documents_id = '%%id'
   %%filesize = @mysql(result,0,0)
      BINFILE OPEN,1,%%file,CREATE
    BINFILE SEEK,1,0
   %%bincounter = 1
   repeat
     if @greater(%%filesize,@fadd(%%bincounter,5000))
       %%binend = 5000
     else
      %%binend = @mod(%%filesize,5000)
     end

     mysql query,select SUBSTRING(documents_document","%%bincounter","%%binend) FROM documents WHERE documents_id = '%%id'

     %%filedata = %%filedata@mysql(result,0,0)
      %%bincounter = @fadd(%%bincounter,5000)
     DIALOG SET,uploadprogress,@format(@fmul(@fdiv(%%bincounter,%%filesize),100),5.0)
   until @greater(%%bincounter,%%filesize)
   DIALOG HIDE,uploadprogress
   BINFILE WRITE,1,%%filedata
   %%filedata =



Can somebody help me on this ?

Thank you very much.

Bye, Fabian
Back to top
View user's profile Send private message Send e-mail Visit poster's website
X-Tools
Valued Contributor
Valued Contributor


Joined: 20 Sep 2001
Posts: 296
Location: Germany

PostPosted: Tue Feb 11, 2003 4:45 pm    Post subject: Binfile Reply with quote

Hi,

today i tested it with fileio from Tommys vdsdll3 pack, and i think
i found the problem in tommys documentation:

With this part of the VDSDLL, you can read from and write to binary files. As the ASCII character 0 cannot be used in VDS strings, binary strings are encoded using a double byte coding system, using the hex equivalents of the ASCII codes of the binary characters.


Could this be my problem with reading binary ?

Thank you for your help.

Bye, Fabian
Back to top
View user's profile Send private message Send e-mail Visit poster's website
X-Tools
Valued Contributor
Valued Contributor


Joined: 20 Sep 2001
Posts: 296
Location: Germany

PostPosted: Wed Feb 12, 2003 7:40 am    Post subject: Binfile Reply with quote

could this problem be because ascii 0 characters in a binfile ?

what can I do to prevent this ? (the file should be uploaded into a database).

yesterday I tested hex uploading - but this files have double size than the original.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Wed Feb 12, 2003 5:18 pm    Post subject: Reply with quote

As far as I know VDS sees the ASCII character 0 as the end of a string..so that would probably be your problem.
What are you using to download the files?
If you are using an extension like vdsipp.dll, maybe you could send the downloaded data right to the fileio dll and not load it into a VDS variable.
Just throwing ideas around, but I hope it gives you something to work with.

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
X-Tools
Valued Contributor
Valued Contributor


Joined: 20 Sep 2001
Posts: 296
Location: Germany

PostPosted: Thu Feb 13, 2003 8:25 am    Post subject: Binfile problem Reply with quote

Hi,

thank you for your answer.
Is the problem only in vds variables ?

I am using vdsmysql.dll and sending to binfile write
(but for the moment i am collecting the data in a variable)

Bye, Fabian
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Fri Feb 14, 2003 4:15 am    Post subject: Reply with quote

I'm honestly not sure, but I would try bypassing the VDS variable and send the information from DLL to DLL if you can.
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
X-Tools
Valued Contributor
Valued Contributor


Joined: 20 Sep 2001
Posts: 296
Location: Germany

PostPosted: Thu Feb 20, 2003 10:12 am    Post subject: Binfile Reply with quote

Hi,

this does also not work.
I am reading directly from binfile into mysql query, but the file
characters (ascii 0) are replaced by dots (i think).

Can anybody help me ?

I can use the hex format but files are as twice as big (2 digits to declare one character).

Thank you.

Bye, Fabian
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group