Coder Social home page Coder Social logo

aerouk / imageserve Goto Github PK

View Code? Open in Web Editor NEW
128.0 9.0 34.0 45 KB

A ShareX image hosting solution for your own domain.

Home Page: https://iaero.me/imageserve

License: GNU General Public License v2.0

CSS 13.36% PHP 47.44% HTML 39.20%
php image sharex

imageserve's People

Contributors

aerouk avatar dkabot avatar linuxgemini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imageserve's Issues

Issue With jpgs

I was having an error viewing jpegs with the viewer. I fixed it tho.

Replace your viewer.php with this

<?php

require_once(__DIR__ . '/protected/config/config.php');

$index = ! (isset($_GET['type']) && isset($_GET['file']));

if ($index) {
    include_once(__DIR__ . '/protected/templates/index.phtml');
    die();
}


$type = $_GET['type'];
$file = $_GET['file'];

if ($type == "jpeg") {
        $stype = "jpg";
    } else {
        $stype = $type;
    }

$filelocation = __DIR__ . "/images/$type/$file.$stype";

if ( ! file_exists($filelocation)) {
    header("HTTP/1.0 404 Not Found");
    include_once(__DIR__ . '/protected/templates/error.phtml');
    die();
}

$filesize = filesize($filelocation);

if (RAW_IMAGE) {
    $filecontents = fopen($filelocation, 'rb');

    header("Content-type: image/$stype");
    header("Content-length: " . $filesize);

    fpassthru($filecontents);
    exit;
} else {
    $time = microtime();
    $time = explode(' ', $time);
    $time = $time[1] + $time[0];
    $start = $time;

    require_once(__DIR__ . '/protected/templates/viewer.phtml');
}

nginx setup

here sample for nginx config

       autoindex on;
       location / {
                try_files $uri $uri/ =404;
                rewrite ^/?$ /viewer.php;
                rewrite ^/([^/\.]+).gif/?$ /viewer.php?type=gif&file=$1;
                rewrite ^/([^/\.]+)(.jpg|.jpeg)/?$ /viewer.php?type=jpeg&file=$1;
                rewrite ^/([^/\.]+)(.png)?/?$ /viewer.php?type=png&file=$1;
        }
        location /g {
                rewrite ^/g/([^/\.]+)(.gif)?/?$ /viewer.php?type=gif&file=$1;
        }

        location /j {
                rewrite ^/j/([^/\.]+)(.jpg|.jpeg)?/?$ /viewer.php?type=jpeg&file=$1;
        }

        location /w {
                rewrite ^/w/([^/\.]+)(.webm)?/?$ /viewer.php?type=webm&file=$1;
        }

Error uploading to nginx?

Hi there. I followed the video tutorial but I get the following error:

Error: Message:
The remote server returned an error: (405) Method Not Allowed.

Request URL:
https://memes.slimshadyime.me/imageserve/upload.php

Response:
<html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx/1.10.3 (Ubuntu)</center>
</body>
</html>


Stack trace:
   at System.Net.HttpWebRequest.GetResponse()
   at ShareX.UploadersLib.Uploader.SendRequestFile(String url, Stream data, String fileName, String fileFormName, Dictionary`2 args, NameValueCollection headers, CookieCollection cookies, ResponseType responseType, HttpMethod method, String contentType, String metadata)

Larger images uploading as domain.com/j/xxxxxx

For some reason, when I upload images, the larger ones seem to be uploading and returning a /j/imagename address while not actually creating a /j folder or anything.

They used to just upload as i.domain.com/xxxxxx.jpg and worked just fine. Now it's adding a /j/ and messing everything up, causing 404s.

I haven't changed anything whatsoever. Just started happening one day with larger images.

No Renaming?

Hey there, is there a easy way for not renaming the files that got uploaded, i mean my share x already apply a timestamp, so there should be no dublicates possible, and i want to sort the images after.

Asks for enabling Javascript in Browser

@aerouk
image
Simply doesn't work, I followed all video instructions. My config is

`<?php

// _
// () A self-hosted ShareX image serving solution.
// _ _ __ ___ __ _ __ _ ___ ___ ___ _ ____ _____
// | | '
_ \ / _ |/ ` |/ _ / |/ _ \ '\ \ / / _
// | | | | | | | (
| | (| | _/_ \ __/ | \ V / __/
// |
|| || ||_,|_, |_||/_|_| _/ _|
// / |
// |
/ created by github.com/aerouk

/* More information on all these values can be found on the wiki page. /
/
https://github.com/aerouk/imageserve/wiki/Configuration */

define('RAW_IMAGE', true);
define('RAW_IMAGE_LINK', false);
define('IMAGE_EXTENSION', false);

define('TWITTER_CARDS', false);

// If you're using this, make sure to put a forward slash before.
// E.g. "/imageserve" not "imageserve"
define('IMAGESERVE_DIR', '/images');
define('TWITTER_HANDLE', '');

define('APP_NAME', 'My App');
define('PASSKEY', 'removed');
`

URL shortener returns 404 - ShareX - IIS

I haven't tested this with Apache, but using IIS, when I turn RAW_IMAGE_LINK to "false" and allow the URL shortener to work, the resulting shortened URL just returns a 404 page. However, when RAW_IMAGE_LINK is "true" and no URL shortener is used, the URL obtained in ShareX works just fine.

Am I missing something here, or is something in the source not properly shortening URLs?

All files don't work

The files are saving to my webserver fine but when I take a screenshot it is just redirecting me to my domain/php without the image name.

Support for other files?

Is it possible to have support for other files as well? Like zip or txt? That would be really useful.

e-500x

I still get the e-500x error but the directories are all writable (777)

WebM

I followed the steps exactly to use webm on my server, yet I just get this as the url 'https://i.theapollo.xyz/e-415'

I dont know whats happening, I copied the steps exactly, and my images work aswell

404 error?

I'm a huge noob.

I put imageserve into a folder named 'imageserve-demo'. This is what happens when I use the test button on ShareX: http://i.william.sh/imageserve-demo/wY4xg

I get a 404 error. I have a feeling this is a very simple fix, and that I am just either a huge noob, or just really tired.

My /images is set to 0777 in WinSCP.

I can provide any files (such as my config.php) if needed.

Thank you! I would like to get this resolved as soon as possible. ๐Ÿ‘

Existing connection error

Hi all, I just did a fresh install of the latest revision, and im getting this error

Message:
Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.

StackTrace:
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.InternalWrite(Boolean async, Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
at System.Net.ConnectStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at UploadersLib.Uploader.TransferData(Stream dataStream, Stream requestStream)
at UploadersLib.Uploader.UploadData(Stream dataStream, String url, String fileName, String fileFormName, Dictionary`2 arguments, NameValueCollection headers, CookieCollection cookies, ResponseType responseType, HttpMethod method)

does this imply that my previous attempt to install still has the connection open? o.o

Files uploading but no image

I've set up your script on a server running PHP 5.6. I get success returned to ShareX but when I try to go to the image there's nothing there. I've checked the images directory and there's nothing in there either. All of the directories are set to 777.

Add an easier way to delete all your pictures

If you add this line of code to your upload.php you can just delete the folder in the image folder.
And then it will make the png/gif/jpg folders by itself. I think you should really implement this :)

if (!file_exists("/" . $dir . "/" . $type . "/")) { mkdir($dir . "/" . $type, 0777); }

No image displayed?

I noticed you didn't also get an image showing up until you changed the permissions to 777 and also recursive thing and after I did that I still do not see any images appear. What might be wrong?

Index showing blank

When I go to the home page of my domain, it shows nothing but a blank page, when I got to the viewer.php, it just shows the homepage and even says it is the homepage in the title. Any idea on how to fix this?

Remove j/g from raw image link

Hi there. I'm @aspiegeek on Twitter and I wasn't sure how to make a pull request (tells me there's nothing to compare and I don't have anything on here) and so this would work better imo. I'm also the one who suggested the raw image link suggestion from May.

Anyway, I'd like to suggest a way to remove the /j/ and /g/ from the raw image link so no matter what type of file it is, it'll always be domain.tld/abc123.xyz rather than /j/abc123.xyz or /g/abc123.xyz. I find it very annoying when I'm uploading and sharing with those two directories.

gif upload doesn't work

My GIF uploads don't work although the rest of the files will, upload all the code is the same on the upload.php file (besides the save destination). It seems to return a 401 error (wrong password but its right passkey).
error 401

Errors for jpg uploads

I have everything up and running fine, png and gif uploads go without a hitch, but jpg uploads have been acting weird. First I was getting e-503 for jpgs, despite all permissions being fine. I renamed the image/jpeg folder to image/jpg and they upload successfully now but result in a 404 when trying to view.

Tried replacing my upload.php with the replacement from addles' earlier issue, both with the folder name image/jpeg and image/jpg, and received the same results.

e-503

So im trying to set this up with Apache2 and I keep getting an e-503 as the url. Any idea what the problem is?

Is there a way to stop this?

I dont want my jpeg images going to a seperate folder, '/j/2kdl7' I want it to be like my PNG files, where it will only goto to the index page, for example 'https://theapollo.xyz/foLyQ'.

Is there a way to make the jpegs not go into the '/j' dir?

Text file support

If you were to add Text file support that would be great, thanks!

E-401 although password is correct

I've triple checked my password and I'm still getting E-401. Here's my ShareX config:
"ShareX config"

And here's my config.php:

//   _
//  (_)    A self-hosted ShareX image serving solution.
//   _ _ __ ___   __ _  __ _  ___  ___  ___ _ ____   _____
//  | | '_ ` _ \ / _` |/ _` |/ _ \/ __|/ _ \ '__\ \ / / _ \
//  | | | | | | | (_| | (_| |  __/\__ \  __/ |   \ V /  __/
//  |_|_| |_| |_|\__,_|\__, |\___||___/\___|_|    \_/ \___|
//                      __/ |
//                     |___/   created by github.com/aerouk

/* More information on all these values can be found on the wiki page. */
/* https://github.com/aerouk/imageserve/wiki/Configuration */

define('RAW_IMAGE', false);
define('RAW_IMAGE_LINK', false);
define('IMAGE_EXTENSION', false);

define('TWITTER_CARDS', false);

// If you're using this, make sure to put a forward slash before.
// E.g. "/imageserve" not "imageserve"
define('IMAGESERVE_DIR', '/');
define('TWITTER_HANDLE', '');

define('APP_NAME', 'RYXN');
define('PASSKEY', "<REDACTED>");```

Any ideas?

Login Page to view and manage pictures

Hello i dont know if you are still working on this project but i would really like if you can add a login page to view images and manage them it would be really cool

File Extension Folder

When creating a screenshot sharex will report it was in the /img directory but is actually in the /img/images/png, gif etc. This really annoys me as i have to find out what filename it is from the server itself.

Updated tutorial

Can we get an updated tutorial? We're now on ShareX 13.1 and things have changed.

uploads redirect to homepage/index.html

upon upload, sharex does seemingly nothing and the preview when clicked directs me to my urls initial webpage, there is no error when i test it, my config and destination settings are in line with setup, and I have written my permissions recursively (albeit on many folders, perhaps this is my issue) i would really love some help with this, i will post a video.

https://streamable.com/nks7t

The requested URL was not found on this server

Hey,

it kinda looks like the viewer is fucked up. I can make Screenshots and I can test the image uploader, but it keeps saying that the requested URL wasnt found on the server.

However the Pictures itself get uploaded and can also be viewed with the complete URL.

Example:
Not working:
https://cleanlegen.de/i/FeK5D
Working:
https://cleanlegen.de/i/images/png/FeK5D.png

Any Idea how to fix?

Here are my Settings:
`<?php

// _
// () A self-hosted ShareX image serving solution.
// _ _ __ ___ __ _ __ _ ___ ___ ___ _ ____ _____
// | | '
_ \ / _ |/ ` |/ _ / |/ _ \ '\ \ / / _
// | | | | | | | (
| | (| | _/_ \ __/ | \ V / __/
// |
|| || ||_,|_, |_||/_|_| _/ _|
// / |
// |
/ created by github.com/aerouk

/* More information on all these values can be found on the wiki page. /
/
https://github.com/aerouk/imageserve/wiki/Configuration */

define('RAW_IMAGE', true);
define('RAW_IMAGE_LINK', false);
define('IMAGE_EXTENSION', false);

define('TWITTER_CARDS', false);

// If you're using this, make sure to put a forward slash before.
// E.g. "/imageserve" not "imageserve"
define('IMAGESERVE_DIR', '/i');
define('TWITTER_HANDLE', '@Electricz_y0');

define('APP_NAME', 'imageserve');
define('PASSKEY', 'dummerhurensohn124323bhj12nn');
`

ShareX:
https://cleanlegen.de/i/images/png/xdC7r.png

I am using cloudflare, but i dont think that this is the problem

Thanks in advance

Multi-user support

  • support for multiple users
    • possibly different directory for each user (configurable)
    • store passwords in database(?)
      • would probably depend on scale of deployment

Video support

To be able to send videos recorded in sharex to imageserve

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.