JoeGandy / ShareX-Custom-Upload

A little PHP script created for uploading custom sharex files to your own webserver
MIT License
166 stars 50 forks source link

ShareX won't upload files #24

Closed TurboCheetah closed 6 years ago

TurboCheetah commented 6 years ago

Error: Message: Too many automatic redirections were attempted.

Request URL: https://redacted/upload.php

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

TurboCheetah commented 6 years ago

Fixed.

EDIT: The issue above. Not the following issue:

TurboCheetah commented 6 years ago

Now I get URL: Sorry, there was a problem uploading your file. (Ensure your directory has 777 permissions). I gave the directory the permissions and I still get it. Edit: And my upload_max_filesize post_max_size are both set to 150M

TurboCheetah commented 6 years ago

Bump

@JoeGandy @DJkikisa

TurboCheetah commented 6 years ago

config.php:

<?php

return array(
    'secure_key' => 'redacted',

    'output_url' => 'https://i.redacted/',

    'redirect_url' => 'redacted',

    'allowed_ips' => '',

    'page_title' => 'Turbo File Host',

    'heading_text' => 'Turbo File Host',
);
?>

upload.php:

<?php
$config = include('config.php');

$key = $config['secure_key'];
$uploadhost = $config['output_url'];
$redirect = $config['redirect_url'];

if ($_SERVER["REQUEST_URI"] == "/robot.txt") { die("User-agent: *\nDisallow: /"); }

if (isset($_POST['key'])) {
    if ($_POST['key'] == $key) {
        $parts = explode(".", $_FILES["d"]["name"]);
        $target = getcwd() . "" . $_POST['name'] . "." . end($parts);
        if (move_uploaded_file($_FILES['d']['tmp_name'], $target)) {
            $target_parts = explode("", $target);
            echo $uploadhost . end($target_parts);
        } else {
            echo "Sorry, there was a problem uploading your file. (Ensure your directory has 777 permissions)";
        }
    } else {
        header('Location: '.$redirect);
    }
} else {
    header('Location: '.$redirect);
}
?>

Edit: It seems to work, but only gives me my domain and not a url to an image.

DJkikisa commented 6 years ago

Looks like mistake in ShareX Configuration part. Since I just tested and when removed name in ShareX it returned me only link with file extension. So redo ShareX Configuration Step 5 and test again :)

TurboCheetah commented 6 years ago

Still not working @DJkikisa... 5ff55

EDIT: Image and I have every file in my root directory (i). I moved the contents of u/ there aswell.

DJkikisa commented 6 years ago
<?php
$config = include('config.php');

$key = $config['secure_key'];
$uploadhost = $config['output_url'];
$redirect = $config['redirect_url'];

if ($_SERVER["REQUEST_URI"] == "/robot.txt") { die("User-agent: *\nDisallow: /"); }

if (isset($_POST['key'])) {
    if ($_POST['key'] == $key) {
        $parts = explode(".", $_FILES["d"]["name"]);
        $target = getcwd() . "/" . $_POST['name'] . "." . end($parts);
        if (move_uploaded_file($_FILES['d']['tmp_name'], $target)) {
            $target_parts = explode("/", $target);
            echo $uploadhost . end($target_parts);
        } else {
            echo "Sorry, there was a problem uploading your file. (Ensure your directory has 777 permissions)";
        }
    } else {
        header('Location: '.$redirect);
    }
} else {
    header('Location: '.$redirect);
}
?>
TurboCheetah commented 6 years ago

Thanks!