flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.62k stars 409 forks source link

Redirect to Image? #465

Closed zQueal closed 2 years ago

zQueal commented 2 years ago

I have two sites being served by caddy;

/var/www/mainsite/
/var/www/i.mainsite/

i.mainsite is a simple curl based image uploader. Both locations are using flight to serve data. mainsite works fine. i.mainsite partly works. I'm able to upload images with my script. However, when I attempt to view them, I get a 404 error.

<?php

require "flight/Flight.php";

Flight::route("POST /", function(){
  include("public/img.php");
});

Flight::start();

Image files are uploaded to public/files/. Here's the tree view;

.
├── flight
│   ├── Engine.php
│   ├── (etc)
├── index.php
└── public
    ├── files
    │   └── HK-5n.jpg
    └── img.php

I've been trying to troubleshoot this for a while, and I can't seem to grasp the methodology I need to use to get this to work. Ideally, I'd like to be able to be PUT images via curl form data to i.mainsite and be able to access the image by i.mainsite/HK-5n.jpg.

Is this even possible?

kuopassa commented 2 years ago

Is the PHP code for viewing images? Because if you're trying to view images with it, notice how it has just POST protocol and not GET.

zQueal commented 2 years ago

Is the PHP code for viewing images?

Yes.

Because if you're trying to view images with it, notice how it has just POST protocol and not GET.

I've also tried GET | POST, to no avail. In my frustration I moved away from Flight. Which is unfortunate.