inhibiting image download - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: inhibiting image download (/showthread.php?tid=79737) |
inhibiting image download - richb201 - 07-24-2021 I am setting a flag like this in __construct() $_SESSION['iUploadImage']=0; Then in _init() I am running if ($_SESSION['iUploadImage']==0) //check to see if already transferred { $this->MyModel->get_image(); //gets images from s3 $_SESSION['iUploadImage']=1; //the files have been transferred } But what I am finding is that $_SESSION['iUploadImage'] keeps getting set back to 0. The goal of this code its to only upload the images once. Any idea why this happens? RE: inhibiting image download - richb201 - 07-25-2021 I am pretty frustrated with this. I tried using a glob var instead of a session var but it doesn;t work either. Here is the decl $GLOBALS['iUploadImage']=0; class Configure extends CI_Controller { and here is the test if ($GLOBALS['iUploadImage']==0) //check to see if already transferred { $this->MyModel->get_image(); //gets images from s3 $GLOBALS['iUploadImage']=1; //the files have been transferred } This downloading reoccurs everytime a user clicks to a new page. Actually not a new page since this is a single page app. I want to download the images only once. It would have been much easier if I just saved the thumbnail in mysql. I wanted to also keep the full image so that users could access it years later, but I am running out of patience with the issue with that. I am using AWS transfer to download the images. The reason I went to S3 at all was the size limitation on MYSQL. While Koolreport can use images directly from mysql, it can't use them from S3. S3 is a much cheaper way to keep large files. I am considering reworking this area (ugh!) and keeping the thumnails up on MYSQL, and only download the actual file when a user asks for it. This speed issue is killing my app. RE: inhibiting image download - InsiteFX - 07-27-2021 Why not use chmod to change the permissions on the image folder? Change it to read only etc; RE: inhibiting image download - richb201 - 07-27-2021 Insite, won't chmod just give me an error when I try copying? I am currently using public function __construct() { static $hasRun=0; parent::__construct(); etc... and then in _init(){ if ($hasRun==0) { $this->MyModel->get_image(); //gets images from s3 $hasRun=1; } I am getting an error that static var $hasRun Message: Undefined variable: hasRun Can not define a static var whose scope is global? RE: inhibiting image download - ojmichael - 07-27-2021 PHP Code: static::$hasRun = 1; RE: inhibiting image download - richb201 - 07-27-2021 static $hasRun=0; Message: Access to undeclared static property: Configure::$hasRun RE: inhibiting image download - InsiteFX - 07-28-2021 it will not give you an error as long as you set it to owner, owner will only allow you access. RE: inhibiting image download - richb201 - 07-28-2021 (07-28-2021, 02:56 AM)InsiteFX Wrote: it will not give you an error as long as you set it to owner, owner will only allow you access. I am actually not the owner. This is running inside a Docker container. When I click on the file in filemanager it says that I am the owner but I think that Docker makes its own copies and who knows who actually owns it. RE: inhibiting image download - richb201 - 07-28-2021 The problem I see with CI3 in general is that there seems to be no way to set up an environment for a first time user. Everything runs ALL THE TIME! Other must have had this problem before? |