Welcome Guest, Not a member yet? Register   Sign In
inhibiting image download
#1

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?
proof that an old dog can learn new tricks
Reply
#2

(This post was last modified: 07-25-2021, 03:51 AM by richb201.)

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.
proof that an old dog can learn new tricks
Reply
#3

Why not use chmod to change the permissions on the image folder?

Change it to read only etc;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

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?
proof that an old dog can learn new tricks
Reply
#5

PHP Code:
static::$hasRun 1
Reply
#6

(This post was last modified: 07-27-2021, 05:46 PM by richb201.)

static $hasRun=0;

Message: Access to undeclared static property: Configure::$hasRun
proof that an old dog can learn new tricks
Reply
#7

it will not give you an error as long as you set it to owner, owner will only allow you access.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#8

(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.
proof that an old dog can learn new tricks
Reply
#9

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?
proof that an old dog can learn new tricks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB