NetTalk Central

Author Topic: File Upload Problem  (Read 3011 times)

osquiabro

  • Hero Member
  • *****
  • Posts: 668
    • View Profile
    • Email
File Upload Problem
« on: March 09, 2015, 05:46:57 PM »
Clarion 10 11643
NT 8.38

I try to create a File Upload to blob but NT generate error with a field, is define as blob in my dct with binary check.

i attach app with dct..

[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11183
    • View Profile
Re: File Upload Problem
« Reply #1 on: March 10, 2015, 12:59:44 AM »
Hi Osa,

Thanks for the example - it shows the root of the problem.

Basically the File Uploader is really expecting you to use 2 fields in the case of a blob - ont to holfd the "File name" and the Blob to hold the file contents.

Because you have set the "Field Name" to be the blob field - that's what is generating all the errors. Typically this should be a String field in your table, which will hold the "name" of the file being uploaded.

If you change to that you should be ok.

cheers
Bruce

osquiabro

  • Hero Member
  • *****
  • Posts: 668
    • View Profile
    • Email
Re: File Upload Problem
« Reply #2 on: March 10, 2015, 08:08:10 AM »
i change the fields and compile ok but don't work to save a blob, i don't if is compatible with SQL Server, my blob field is requiered in database and when try to save the field is null, the image is downlod correctly in upload directory but not to database.

[attachment deleted by admin]
« Last Edit: March 10, 2015, 08:27:23 AM by osquiabro »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11183
    • View Profile
Re: File Upload Problem
« Reply #3 on: March 10, 2015, 09:58:14 PM »
it looks like you have a constraint on the blob field to not allow nulls. Is that the case?

cheers
Bruce

osquiabro

  • Hero Member
  • *****
  • Posts: 668
    • View Profile
    • Email
Re: File Upload Problem
« Reply #4 on: March 11, 2015, 04:22:04 AM »
yes is the case, but without null restriction same problem.

I have a same problem that this post :

http://www.nettalkcentral.com/index.php?option=com_smf&Itemid=36&topic=5502.0

with sql server the blob field is clear before save a record i try this code in SaveFile Routine :

IF FileToBlob(Doc:DocName,Doc:DocContent)  !returns an ERRORCODE if copy fails
 MESSAGE(CLIP(Doc:DocName) & ' was not copied -  ERRORCODE: ' & ERRORCODE())
END
message(Documents.DocContent{PROP:Size})
This code is a same that a desktop app

this code don't generate any error the blob field have a size but don't why the value is clear before save a record.


With TPS work perfect.

« Last Edit: March 11, 2015, 04:24:19 AM by osquiabro »

osquiabro

  • Hero Member
  • *****
  • Posts: 668
    • View Profile
    • Email
Re: File Upload Problem
« Reply #5 on: March 11, 2015, 05:11:59 AM »
i see the CheckForDuplicate  Routine delete the value of blob field with sql server i add this codefor ommit the routine and work:

what is wrong?

CheckForDuplicate  Routine
  If loc:invalid <> '' then exit. ! no need to check, record is already invalid
  If ans = 0 then exit. ! no need to check, as no action happening
  ! Start of "On Insert / Copy / Update : Checking for Duplicate : before disk write (start)"
  ! [Priority 5000]
  if 0=1
  ! End of "On Insert / Copy / Update : Checking for Duplicate : before disk write (start)"
  If p_web.GetSessionValue('UpdateDocuments:Primed') = 0 and Ans = Net:InsertRecord
    Get(Documents,0)
  End
  ! Check for duplicates
  If Duplicate(Doc:PK_Documents)
    loc:Invalid = 'Doc:DocId'
    if not loc:alert then loc:Alert = clip(p_web.site.DuplicateText) & ' PK_Documents --> '&clip('Doc Id:')&' = ' & clip(Doc:DocId).
  End
  ! Start of "On Insert / Copy / Update : Checking for Duplicate : before disk write (end)"
  ! [Priority 5000]
  end

osquiabro

  • Hero Member
  • *****
  • Posts: 668
    • View Profile
    • Email
Re: File Upload Problem
« Reply #6 on: March 11, 2015, 05:25:46 AM »
this code cause the problem:

If Duplicate(Doc:PK_Documents)

i think that the problem is because i have a identity field for my primary key, and this moment the value is 0 and cause the error.

osquiabro

  • Hero Member
  • *****
  • Posts: 668
    • View Profile
    • Email
Re: File Upload Problem
« Reply #7 on: March 11, 2015, 07:20:07 AM »
another issue, the technique of NT for save a blob in sql server save a corrupt file but with this code in Valide Insert Routine work perfect:

i#=FileToBLOB(p_web.GSV('Cod:DocumentDescription'),Cod:DocumentContent)

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11183
    • View Profile
Re: File Upload Problem
« Reply #8 on: March 11, 2015, 07:47:53 AM »
>> another issue, the technique of NT for save a blob in sql server save a corrupt file

try with 8.41


osquiabro

  • Hero Member
  • *****
  • Posts: 668
    • View Profile
    • Email
Re: File Upload Problem
« Reply #9 on: March 11, 2015, 08:38:37 AM »
don't work entirely, if upload a pdf fine, but any image failed