📜 ⬆️ ⬇️

RE: Idea on the subject of large images and limitations of hosting

This post is a response to the idea set forth in this topic.

The bottom line: you are the owner of the site and you need to resize the image flooded by the user, but you do not have enough opportunities for this.
Solution: We do for you a "proxy" that does everything for you and gives your script the result.
How to use:

In the form of filling the image you write about the following

<form enctype="multipart/form-data" action="http://sjpg.ru/remoteupload.php" method="post" />
Image:
<input name="Image" type="file" size="85" > <input type="submit" value="Upload" />
<input type="hidden" name="maxwidth" value=" 600 " />
<input type="hidden" name="maxheight" value=" 700 " />
<input type="hidden" name="quality" value=" 70 " />
<input type="hidden" name="destination" value=" sjpg.ru/upload.php " />
<input type="hidden" name="redirecturl" value=" ya.ru " />
</form>

')
where sjpg.ru/remoteupload.php is our proxy;
destination is your script to which we will upload the image in the Image field, it will also receive all the fields for the request that the user will send to us (this way you can transfer sessions);
redirecturl - here the server will send the user after the download is completed, but most likely before the picture gets to your server .
In this example, I upload a picture to my website and send the user to Yandex.

But in general, that's all.
The service is very raw and is now blasphemed on the state sharingharing. If there is interest, we transfer it to Maskva for VDS for example.
The problem is quite specific and there may not be so many fans.

Try and be sure to write reviews.

upd :
Sample php code that downloads a picture for the session and then displays it for the user with this session. This code is just a demonstration, do not do it in production :)

<?php
if(isset($_FILES['Image'])&&isset($_POST['imageId'])){
move_uploaded_file($_FILES['Image']['tmp_name'], "images/".intval($_POST['imageId']).".jpg");
}
else{
session_start();
if(isset($_SESSION['imageId'])) {
echo '<img src="/images/'.$_SESSION['imageId'].'.jpg" />';
}
else {
$_SESSION['imageId']= rand();
?>
<form enctype="multipart/form-data" action="http://sjpg.ru/remoteupload.php" method="post" />
Image:
<input name="Image" type="file" size="85" > <input type="submit" value="Upload" />
<input type="hidden" name="maxwidth" value=" 120 " />
<input type="hidden" name="maxheight" value=" 120 " />
<input type="hidden" name="quality" value=" 85 " />
<input type="hidden" name="destination" value=" yourdomain.domain/test.php " />
<input type="hidden" name="redirecturl" value=" yourdomain.domain/test.php " />
<input type="hidden" name="imageId" value="<?php echo $_SESSION['imageId']; ?>" />
</form>

<?php
}
}
?>


You can try this thing as a client at c2009.ru/test.php , there is exactly the same code, only the domain is different.

Source: https://habr.com/ru/post/47558/


All Articles