hello
Can someone guide me, to upload a file to a longblod field that has the following characteristics and then download it?
zprs_file_blob
zprs_file_name
zprs_file_type
I had it solved before with the nubulder 4 version.
With version 4.5 I could not
I appreciate the help please
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
upload file longBLOB
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
Re: upload file longBLOB
Hi, thanks for your attention.
Use an Iframe to upload the file.
Iframe Php to run file: upload file
Php code
$h = "
<html>
<body style='background-color:lightgrey'>
<form enctype='multipart/form-data' action='nuupload.php' method='POST'>
<input name='userfile' type='file' />
<input type='submit' value='Send File' />
</form>
</body>
</html>
";
print $h;
In the after save of the form
$J = json_decode("#FILES#");
if($J[0]->name == ''){return;}
$dt = new DateTime();
$date = $dt->format('Y-m-d H:i:s');
$name = $J[0]->name;
$type = $J[0]->type;
$size = $J[0]->size;
$uploaddir = sys_get_temp_dir();
$contents = file_get_contents($uploaddir . '/' . $J[0]->name);
$contents = addslashes($contents);
nuDebug($contents);
$s = "
UPDATE plan_inversiones
SET
zprs_file_blob = '$contents',
zprs_file_name = '$name',
zprs_file_type = '$type',
sfi_size = '$size',
zzzsys_file_log_changed_at = '$date'
WHERE pai_id = '#RECORD_ID#'
";
nuRunQuery($s);
unlink('tmp/' . $J[0]->name);
Use an Iframe to upload the file.
Iframe Php to run file: upload file
Php code
$h = "
<html>
<body style='background-color:lightgrey'>
<form enctype='multipart/form-data' action='nuupload.php' method='POST'>
<input name='userfile' type='file' />
<input type='submit' value='Send File' />
</form>
</body>
</html>
";
print $h;
In the after save of the form
$J = json_decode("#FILES#");
if($J[0]->name == ''){return;}
$dt = new DateTime();
$date = $dt->format('Y-m-d H:i:s');
$name = $J[0]->name;
$type = $J[0]->type;
$size = $J[0]->size;
$uploaddir = sys_get_temp_dir();
$contents = file_get_contents($uploaddir . '/' . $J[0]->name);
$contents = addslashes($contents);
nuDebug($contents);
$s = "
UPDATE plan_inversiones
SET
zprs_file_blob = '$contents',
zprs_file_name = '$name',
zprs_file_type = '$type',
sfi_size = '$size',
zzzsys_file_log_changed_at = '$date'
WHERE pai_id = '#RECORD_ID#'
";
nuRunQuery($s);
unlink('tmp/' . $J[0]->name);
You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact: