Wednesday, February 27, 2013 5:47:45 PM

Hi,

Using Active4D 6.0r6, 4D 12.4 on Mac 10.6.8, using both Safari and FireFox, 
I've run into the following problem with file uploads.

I have a simple form with the following:

<form method="post" action="return.a4p" enctype="multipart/form-data">
<input type="file" name="A4D_Upload" size="40"><br><br>
Notes on this file:<br>
<textarea name="f_newnotes" cols="70" rows="10"> </textarea><br>
<input TYPE="submit" name="f_ReturnBtn" VALUE="Return file">
</form>

Now, when I submit the form without specifying any file to upload, I get all of 
the fields listed:

A4D_Upload
f_newnotes
f_ReturnBtn

I see this in the debugging dump code I have on the "return.a4p".

However, as soon as I select a file on the form and submit it, the "A4D_Upload" 
field drops off the list of fields submitted. (Maybe this is correct?)

Still, I can use the following commands:

$vSize:=get upload size("A4D_Upload")
$vName:=filename of(get upload remote filename("A4D_Upload"))

and I get values, so the upload must be there.

Finally, however, when I use the following command:

$vNotUsed:=save upload to field("A4D_Upload";[Docs]Fork_Data)

where "[Docs]Fork_Data" is a BLOB field in the database, I get an Active4D 
error on this line of code with the message:

Reference to an undefined variable or value

I tried both versions of this command, using a direct field reference, and then 
a pointer to the field, and both of them throw an error on this line.

Anybody have any ideas what I might be doing wrong here?

I finally programmed around it by using the "copy upload" Active4D command to 
save the uploaded file. But even that had problems; I had the following code:

$vCurrPath:=directory of(current path)+$vName
copy upload("A4D_Upload";$vCurrPath)
DOCUMENT TO BLOB($vCurrPath;[Docs]Fork_Data)

but again, Active4D barfed on the "DOCUMENT TO BLOB" command (same error, 
"reference to an undefined...").

I finally got it working with the following code:

$vCurrPath:=directory of(current path)+$vName
copy upload("A4D_Upload";$vCurrPath)
C_BLOB($vBLOBFile)
DOCUMENT TO BLOB($vCurrPath;$vBLOBFile)
[Docs]Fork_Data:=$vNewFile

However, seems like a lot of workaround instead of just using the nice, one 
line command "save upload to field". Plus, now I've got a bunch of copies of 
the uploaded document floating around:

1) the original upload that Active4D receives
2) the copy from "copy upload"
3) another copy in the $vBLOBFile variable
4) and finally, the file where I want it in [Docs]Fork_Data

Of course, I can delete #2 and #3 right away, and Active4D will get rid of #1 
automatically; still, if I've got a large file, that's a lot of copies (and 
memory) that's getting eaten up by this file.

It seems like somehow Active4D doesn't like a field reference to a BLOB; at 
least that's where I keep getting the error message in several of the commands 
(in both "save upload to field" and "DOCUMENT TO BLOB"), until I use a 
variable, then copy this into the field. Also the "save upload to field" 
command doesn't seem to work either using a direct field reference or a pointer 
to that field. 

Again, am I doing something wrong in any of my previous attempts (prior to the 
workaround version)?

Thanks!

Michael Larue



_______________________________________________
Active4D-dev mailing list
[email protected]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/

Reply via email to