Space Usage For File Uploads for Users

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Space Usage For File Uploads for Users

Post by mqley » 2020-07-19 19:40

Hi, I mentioned to support about the following and it has been put forward for possible future implementation.

Here's was my question to support and what I'm trying to achieve:

"I have a question about file uploads for users. Its great that its allowed, but what about storage? I can't see any information on this. For example, I have a hosting setup for a user application, each user can upload to the server via the application. I understand you can set a limit on each document size, but what about overall space used per user?

Lets say I other a free service to start. But can't track my uploads per user. The idea would be to offer a free user account for X amount of web
space, but if they go beyond this then they may need to pay for an account. Paying for an account etc can be done via a bespoke website, but how would we track the users uploads allocation from within the AppGini app? Maybe it's already built-in to Appgini? If not I would think this is something that could be added for future updates as it strikes me as very important now I've put some thought into it. Please let me know. Great software by the way! Regards, Mark"

Response for this was:

"Hi Mark, You could control per-user upload quota using the tablename_before_insert and tablename_before_update hooks. These 2 hooks allow you to inspect the user-provided data before inserting/updating the table. You'd need to keeptrack of user's upload quota and usage, possibly in a separate table, and make a check in those hooks to determine whether the user can upload a new file or not.

I've also added your suggestion to our roadmap for possible implementation in future releases."

Ok, so was interesting to find out it may be possible with some bespoke work via function table_before_insert(&$data, $memberInfo, &$args) {

But after having a look I really don't know where to start with this. For example I can run the code:

echo '<pre>';
var_dump($data);
echo '</pre>';
exit(); (thanks Jan)

Which brings up the following when uploading provides:

array(3) {
["catalogue_title"]=>
string(0) ""
["title_research"]=>
string(0) ""
["upload_file"]=>
string(21) "782a26c8c2361f718.png"
}

So somehow I would need to know the size of the file. Then add it to a table list of other files uploaded via the user to track the amount uploaded. I don't know how that would work - and what if they removed files too. Calculate that somehow.

Maybe too much for me to take on at present but would welcome any feedback. Maybe someone has done something similar etc.

Regards, Mark
Best Wishes,

Mark

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Space Usage For File Uploads for Users

Post by pbottcher » 2020-07-19 20:13

Hi,

you can access the $_FILES array which holds the data of the uploaded file (s).

e.g. $_FILES['file_load']['size'] will give you the filesize.

So you could store the sum of the uploads for a user in a field and update it upon insert/update and delete accordingly.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-19 21:05

Hi, thanks for this. Would that be a DB field? Not sure how to implement at this point but I'll have a play around. Appreciate the feedback. Regards, Mark
Best Wishes,

Mark

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-21 05:45

Really not sure where to begin. Anyone got any clues as to how this could be programmed. I could do with a few starting points as very new to AppGini. Thanks.
Best Wishes,

Mark

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Space Usage For File Uploads for Users

Post by jsetzer » 2020-07-21 07:50

Hi,

as a starting point for your own implementation. This code works for me with my table- and column-names. You will have to replace TABLENAME and configure a few variables. I have paid attention to making it configurable.

Regards,
Jan
---



TODO
  • add a field "file_size" (big integer or integer) to TABLENAME
  • add a field "memberID" varchar(100) to TABLENAME
  • generate your code and rebuild fields in Admin area, if not done automatically
  • create the following PHP functions in hooks/TABLENAME.php:

    Code: Select all

    // (1)
    function TABLENAME_before_save_check_quota(&$data, $memberInfo, $args)
    {
    
    	// config
    	$table_name = "TABLENAME";
    	$fieldname_file = "file";
    	$fieldname_filesize = "file_size";
    	$fieldname_memberID = "memberID";
    
    	$limit_mb = 1; // MB
    	// end of config
    
    	$limit_bytes = $limit_mb * 1024 * 1024;
    	$fieldname_pk = getPKFieldName($table_name);
    	$pk = $data[$fieldname_pk];
    	$memberID = $memberInfo['username'];
    	$data['memberID'] = $memberID;
    
    	// 1. get total amount of disk space usage for this member
    	$usage_bytes = uploads_get_usage($data, $memberInfo, $args, $table_name, $fieldname_filesize, $fieldname_memberID);
    
    	// 2. get size of uploaded file
    	$new_file_size = $_FILES[$fieldname_file]['size'];
    	$data[$fieldname_filesize] = $new_file_size;
    
    	// calc and check
    	$diskspace_required = ($usage_bytes + $new_file_size);
    	$diskspace_available = $limit_bytes - $usage_bytes;
    	$is_allowed = $diskspace_required <= $limit_bytes;
    
    	// dump for testing purposes
    	echo '<pre>';
    	var_dump("usage: " . $usage_bytes);
    	var_dump("file size: " . $new_file_size);
    	var_dump("required: " . $diskspace_required);
    	var_dump("available: " . $diskspace_available);
    	var_dump("upload allowed: " . $is_allowed);
    	echo '</pre>';
    
    	if (!$is_allowed) {
    		// do whatever you want here
    		// $_SESSION["message-insert_error"] = "Cannot save uploaded file. Available storage space exceeded.";
    // for testing: uncomment next line -----------------------------------
    //                exit;
    	}
    	// 3. check usage
    	return $is_allowed;
    }
    

    Code: Select all

    // (2)
    function TABLENAME_get_usage($data, $memberInfo, $args, $table_name, $fieldname_filesize, $fieldname_memberID)
    {
    
    	$memberID = $memberInfo['username'];
    	$fieldname_pk = getPKFieldName($table_name);
    	$pk = isset($data[$fieldname_pk]) ? $data[$fieldname_pk] : (isset($data["selectedID"]) ? $data["selectedID"] : null);
    
    	$sql = "SELECT IFNULL(sum({$fieldname_filesize}),0) 
    		FROM `{$table_name}` 
    		WHERE `{$fieldname_memberID}`='{$memberID}'"
    		. ($pk ? " AND `{$fieldname_pk}` != '{$pk}'" : null);
    
    	return sqlValue($sql);
    }
    
  • hooks/TABLENAME.php - fx TABLENAME_before_insert:

    Code: Select all

    function TABLENAME_before_insert(&$data, $memberInfo, &$args)
    {
    	return TABLENAME_before_save_check_quota($data, $memberInfo, $args);
    }
    
  • hooks/TABLENAME.php - fx TABLENAME_before_update:

    Code: Select all

    function TABLENAME_before_update(&$data, $memberInfo, &$args)
    {
    	return TABLENAME_before_save_check_quota($data, $memberInfo, $args);
    }
    

Bonus material

Wanna see the current users already used disk space:
chrome_1GlmH9ef2k.png
chrome_1GlmH9ef2k.png (1.17 KiB) Viewed 6609 times
  • add the following code at the beginning of hooks/TABLENAME.php - fx TABLENAME_dv

    Code: Select all

    function TABLENAME_dv($selectedID, $memberInfo, &$html, &$args) {
    	// config
    	$table_name = "uploads";
    	$fieldname_filesize = "file_size";
    	$fieldname_memberID = "memberID";
    	// end of config
    	
    	$html .= '<div class="panel-footer"><i class="glyphicon glyphicon-hdd"></i> ' . number_format(uploads_get_usage($selectedID, $memberInfo, $args, $table_name, $fieldname_filesize, $fieldname_memberID)) . ' Bytes</div>';
    	// ... the rest of your _dv code
    }
    

Cons
  • Due to AppGini's handling when TABLENAME_before_insert returns FALSE, users will be redirected to table view and will NOT stay in detail view.

Ideas for improvement
  • Limit is configured in code. Should be stored in an additional membership- or orders-table.
  • Show a better message after upload has been denied.
  • Clientside validation and message BEFORE upload to avoid data loss
  • Footer: usage / quota in percent of available disk space
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-21 19:12

Hi Jan, thanks for this. I'll have a look at adding in shortly. Really appreciate the work you've put in. Regards, Mark
Best Wishes,

Mark

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-23 12:47

Hi Jan, I'm making some progress, however the Bytes (shown in your screenshot) are zero for me. I suspect its because the mysql table file_size remains empty for some reason, but not sure why. I've attached an image of the db. Where would I look to find the answer to a NULL file_size. Thanks
Attachments
mysql.png
mysql.png (143.67 KiB) Viewed 6552 times
Best Wishes,

Mark

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-23 12:52

Here's all my code for the research table Jan. Thanks.

Code: Select all

<?php
	// For help on using hooks, please refer to https://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks



// (1)
function research_before_save_check_quota(&$data, $memberInfo, $args)
{

	// config
	$table_name = "research";
	$fieldname_file = "file";
	$fieldname_filesize = "file_size";
	$fieldname_memberID = "memberID";

	$limit_mb = 1; // MB
	// end of config

	$limit_bytes = $limit_mb * 1024 * 1024;
	$fieldname_pk = getPKFieldName($table_name);
	$pk = $data[$fieldname_pk];
	$memberID = $memberInfo['username'];
	$data['memberID'] = $memberID;

	// 1. get total amount of disk space usage for this member
	$usage_bytes = research_get_usage($data, $memberInfo, $args, $table_name, $fieldname_filesize, $fieldname_memberID);

	// 2. get size of uploaded file
	$new_file_size = $_FILES[$fieldname_file]['size'];
	$data[$fieldname_filesize] = $new_file_size;

	// calc and check
	$diskspace_required = ($usage_bytes + $new_file_size);
	$diskspace_available = $limit_bytes - $usage_bytes;
	$is_allowed = $diskspace_required <= $limit_bytes;

	// dump for testing purposes
	echo '<pre>';
	var_dump("usage: " . $usage_bytes);
	var_dump("file size: " . $new_file_size);
	var_dump("required: " . $diskspace_required);
	var_dump("available: " . $diskspace_available);
	var_dump("upload allowed: " . $is_allowed);
	echo '</pre>';

	if (!$is_allowed) {
		// do whatever you want here
		// $_SESSION["message-insert_error"] = "Cannot save uploaded file. Available storage space exceeded.";
// for testing: uncomment next line -----------------------------------
//                exit;
	}
	// 3. check usage
	return $is_allowed;
}



// (2)
function research_get_usage($data, $memberInfo, $args, $table_name, $fieldname_filesize, $fieldname_memberID)
{
	$table_name = "research";
	$memberID = $memberInfo['username'];
	$fieldname_pk = getPKFieldName($table_name);
	$pk = isset($data[$fieldname_pk]) ? $data[$fieldname_pk] : (isset($data["selectedID"]) ? $data["selectedID"] : null);

	$sql = "SELECT IFNULL(sum({$fieldname_filesize}),0) 
		FROM `{$table_name}` 
		WHERE `{$fieldname_memberID}`='{$memberID}'"
		. ($pk ? " AND `{$fieldname_pk}` != '{$pk}'" : null);

	return sqlValue($sql);
}



	function research_init(&$options, $memberInfo, &$args) {

		return TRUE;
	}

	function research_header($contentType, $memberInfo, &$args) {
		$header='';

		switch($contentType) {
			case 'tableview':
				$header='';
				break;

			case 'detailview':
				$header='';
				break;

			case 'tableview+detailview':
				$header='';
				break;

			case 'print-tableview':
				$header='';
				break;

			case 'print-detailview':
				$header='';
				break;

			case 'filters':
				$header='';
				break;
		}

		return $header;
	}

	function research_footer($contentType, $memberInfo, &$args) {
		$footer='';

		switch($contentType) {
			case 'tableview':
				$footer='';
				break;

			case 'detailview':
				$footer='';
				break;

			case 'tableview+detailview':
				$footer='<div class="iframe-container"><iframe src="hooks/google-iframe.php" allowfullscreen></iframe></div>';
				break;

			case 'print-tableview':
				$footer='';
				break;

			case 'print-detailview':
				$footer='';
				break;

			case 'filters':
				$footer='';
				break;
		}

		return $footer;
	}

	function research_before_insert(&$data, $memberInfo, &$args) {


		return research_before_save_check_quota($data, $memberInfo, $args);

		// return TRUE;
	}

	function research_after_insert($data, $memberInfo, &$args) {

		return TRUE;
	}

	function research_before_update(&$data, $memberInfo, &$args) {
			return research_before_save_check_quota($data, $memberInfo, $args);
		
		//return TRUE;
	}

	function research_after_update($data, $memberInfo, &$args) {

		return TRUE;
	}

	function research_before_delete($selectedID, &$skipChecks, $memberInfo, &$args) {

		return TRUE;
	}

	function research_after_delete($selectedID, $memberInfo, &$args) {

	}


	
	function research_dv($selectedID, $memberInfo, &$html, &$args) 
{
	// config
	$table_name = "research";
	$fieldname_filesize = "file_size";
	$fieldname_memberID = "memberID";

	// end of config
	
	$html .= '<div class="panel-footer"><i class="glyphicon glyphicon-hdd"></i> ' . number_format(research_get_usage($selectedID, $memberInfo, $args, $table_name, $fieldname_filesize, $fieldname_memberID)) . ' Bytes</div>';
	// ... the rest of your _dv code
}



	

	function research_csv($query, $memberInfo, &$args) {

		return $query;
	}
	function research_batch_actions(&$args) {

		return array();
	}
Best Wishes,

Mark

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Space Usage For File Uploads for Users

Post by jsetzer » 2020-07-23 13:17

I think you did not configure your specific fieldname where it says // config

Code: Select all

	$fieldname_file = "file";
should be

Code: Select all

	$fieldname_file = "upload_file";
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-23 15:58

Thanks - it works - just bought you a coffee! Really do appreciate the help there and its help me understand it all a bit more. Thank you.
Best Wishes,

Mark

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Space Usage For File Uploads for Users

Post by jsetzer » 2020-07-23 16:03

Great, well done! I'm glad it works with your database with only little configuration. Thanks for the coffee!
Regards,
Jan
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-23 17:32

I noticed I can trick it by 'Upload new file' and replacing a file with another. I guess that will be another function to take care of that. Looking at the source I have:

<input type="checkbox" name="upload_file_remove" id="upload_file_remove" value="1">

So I'll have a play around with that to see what can be done.
Best Wishes,

Mark

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-24 15:48

Sorry realised my last post wasn't clear. I can Upload a new file in the place of an existing one and the bytes keep the same, rather than amending to account for the new upload file size. I'm having a go to see how to rectify and will update this post if I can come up with a solution - for anyone else aiming to achieve similar. Thanks.
Best Wishes,

Mark

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-25 09:43

Hi, what function is called (if any) when an upload is replaced on the same entry - so in edit mode - you replace a file with another one? Thanks.
Best Wishes,

Mark

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Space Usage For File Uploads for Users

Post by jsetzer » 2020-07-25 13:44

Code: Select all

TABLENAME_before_update
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-25 17:19

Thanks Jan, but that doesn't appear the case when re-uploading - it doesn't get triggered. I did try all the functions in TABLE.php but none get triggered, so wondered if it was possible or not. Thanks.
Best Wishes,

Mark

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Space Usage For File Uploads for Users

Post by jsetzer » 2020-07-25 18:30

When updating a record in AppGini apps, using the Save button in Detail View (DV), TABLENNAME_before_update, then, if returned TRUE, TABLENAME_after_update will be executed. If this does not happen in your app, you may have a spelling mistake or for example did not replace TABLENAME or did not change the correct hooks file TABLENAME.php in hooks subdirectory.

If all is setup correctly, this will definately be executed.

It is definitely possible. We Appginers are using this again and again in our apps. So there will be an error in your code. By the way: you said TABLE.php. it has to be named according to your real table name, for example hooks/contacts.php. also the function require the correct name, for example contacts_before_update.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-25 19:03

Thanks Jan, I'd forgot the exit; code so wasn't seeing the dump. Doh...
Best Wishes,

Mark

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-25 19:16

So looking back over the code you created Jan. I don't understand why the 'Bytes' doesn't update then.

This is the code we run. Then if I'm not mistaken, lastly, the research_dv would run and update the html output, but it doesn't change when I update an image. Looks like the code is already there but it doesn't work as I expect on updating. Thanks.

Code: Select all

function research_before_update(&$data, $memberInfo, &$args) {
			return research_before_save_check_quota($data, $memberInfo, $args);
		
		//return TRUE;
	}
	
	
	function research_dv($selectedID, $memberInfo, &$html, &$args) 
{
	// config
	$table_name = "research";
	$fieldname_filesize = "file_size";
	$fieldname_memberID = "memberID";

	// end of config
	
	$html .= '<div class="panel-footer"><i class="glyphicon glyphicon-hdd"></i> ' . number_format(research_get_usage($selectedID, $memberInfo, $args, $table_name, $fieldname_filesize, $fieldname_memberID)) . ' Bytes</div>';
	// ... the rest of your _dv code




}
	
Best Wishes,

Mark

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Space Usage For File Uploads for Users

Post by jsetzer » 2020-07-26 08:44

Tab 1: Open one testing record and find the disk space usage in bytes at the bottom of the DV.

Tab 2: Open your database tool (for example phpMyAdmin or Adminer), find the testing record and just change the file_size right inside the database table. For example increment by 1.

Tab 1: Reload the browser page. The usage should be different now, for example incremented by 1.

If this works,
A) the _dv code is correct
B) the usage calculation is correct
and
C) there may be a problem in your update procedure.

As mentioned in the very beginning: the code works for me and I have published it as a starting point. It works for me even when updating records and replacing an uploaded file by a different one.

I recommend adding more var_dump()-logging and exit; statements for narrowing down.

Regards,
Jan
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-26 10:50

Thanks Jan - yet again. Enjoying it though.
Best Wishes,

Mark

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-26 14:40

Hi Jan, its C then after testing.

I'm running this function you provided, so not sure why it won't work on mine.

Is this the right function to run? As its 'C there may be a problem in your update procedure." I don't really have any other code to check.

Code: Select all

	function research_before_insert(&$data, $memberInfo, &$args) {




		return research_before_save_check_quota($data, $memberInfo, $args);

	// return TRUE;
	}
p.s. Enjoying the javascript library now ;-)
Best Wishes,

Mark

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Space Usage For File Uploads for Users

Post by jsetzer » 2020-07-27 13:11

Hmmm... you are writing about problems on update, but you have posted code of _after_insert in your last post.

Are you sure you have included the function call in research_after_update, too?

See point 6 of TODO in my first answer above.

Regards,
Jan
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Space Usage For File Uploads for Users

Post by mqley » 2020-07-27 21:13

Sorry Jan, I may have posted wrong part. This is what I have regarding update so far. Thanks.

Code: Select all

	function research_before_update(&$data, $memberInfo, &$args) {
			
	
	/*
	echo '<pre>';
	var_dump("usage: " . $usage_bytes);
	var_dump("file size: " . $new_file_size);
	var_dump("required: " . $diskspace_required);
	var_dump("available: " . $diskspace_available);
	var_dump("upload allowed: " . $is_allowed);
	echo '</pre>';

		exit;

		*/
			return research_before_save_check_quota($data, $memberInfo, $args);

		//return TRUE;
	}

	function research_after_update($data, $memberInfo, &$args) {
	

		return TRUE;
	}

Best Wishes,

Mark

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Space Usage For File Uploads for Users

Post by jsetzer » 2020-07-27 21:37

Well, there is unnecessary code in _before_update which cannot work, but you have already commented it out. So this is not the problem.

_before_update code looks correct.

I cannot see any mistakes in the parts you have published.

You could test replacing an existing file with a 0 bytes file and compare the total usage.

As the limit is still 1MB in your code, maybe replacing an existing file and saving the same record breaks the limit and therefore update returns FALSE and will not be executed. If this was the case: that's by design and not a bug.

Sorry, at this point I cannot help without having a deeper look into your actual PHP code and database.

Regards,
Jan
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Post Reply