Rouji / single_php_filehost

Simple Filehosting Page in a Single PHP File (obvious 0x0 clone)
ISC License
238 stars 31 forks source link

Using a filename besides index.php will not properly return the right URL after uploading #29

Closed csprr closed 3 months ago

csprr commented 4 months ago

Steps: Use this php file as upload.php instead of index.php Upload file Get uploaded url returned as https://image.example.tld/**upload.php**aN4-nR5o.png

For me it's as simple as just removing the $_SERVER['REQUEST_URI'] from SITE_URL(), but then the generated configs for sharex and hupl are incorrect again. Which can be solved in my case by adding the above to those again though.

Rouji commented 4 months ago

Oh yeah, that's making one or two very obviously dumb assumptions about the webserver config there I'll need to have a think about that

csprr commented 4 months ago

Oh yeah, that's making one or two very obviously dumb assumptions about the webserver config there I'll need to have a think about that

Additionally, $_SERVER['HTTPS'] will return false if a reverse proxy is used to a http endpoint. In my case http is forwarded to https either way, but I assume other people might not always have that.

Rouji commented 4 months ago

it's exactly not automagic, but you can set fastcgi_param HTTPS 'on'; to get https behaviour behind a reverse proxy

Rouji commented 3 months ago

@csprr any chance you can try https://github.com/Rouji/single_php_filehost/tree/url-fix in your setup?

csprr commented 3 months ago

@csprr any chance you can try https://github.com/Rouji/single_php_filehost/tree/url-fix in your setup?

Works perfect now:

Thank you for fixing it.

Rouji commented 3 months ago

Neat, thanks!