A new task has come up - are there any pre-existing scripts available that can facilitate server uploads and generate a link to the uploaded file, similar to how conventional image hosting platforms work?
The ideal solution would involve minimal coding, with basic checks already implemented. Do you have any suggestions or recommendations on this topic?
Do you think a file manager is what's needed? There are plenty of them available online, some paid and some free. Personally, I believe the file uploading system in WordPress is well-organized, at least within the allowable limits set by your hosting provider.
Quote from: Newport on Aug 02, 2022, 04:17 AMFile manager or what?
Not quite sure what it is called file manager. I can't find anything related to this query.
This is not a file manager script that can be found on the internet.
I need the user to be able to log in, upload an image file to the server in a certain form, and get a public link. Which could then be sent to social networks, posted on another resource. Everything seems to be simple.
Quote from: Stranger on Aug 02, 2022, 05:42 AMI can't find anything related to this query.
Perfect fit
https://phphq.net/php-scripts?script=phUploader&script=phUploader#phUploader
Try it. Let me know how it went. :)
_AnnA_, I also checked. It works.
test 2022-08-02.png
Now we need a script that displays the received address in a convenient form for downloading by the user. Well, in order to be able to immediately share on Facebook, Instagram, and other social networks.
Agree, in this form to give: http://portalsphere.free.fr/phUploader/uploads/1659505256.jpg - not comme il faut.
Well, I think so. Maybe
Stranger has it all, I don't know.
Post Merge: Aug 02, 2022, 09:50 AM
Quote from: Newport on Aug 02, 2022, 07:33 AMWell, in order to be able to immediately share on Facebook, Instagram, and other social networks.
Did you mean this?
screen_89341.png
The author's site is no longer working, I will give a machine translation.
CF ImageHost.Script for organizing image hosting. Easy installation and control of photo hosting (sharing). With features such as preview generation, social media link generation for each individual image, image hosting.
Through the admin panel, you can get detailed data on traffic usage. A very important feature: pictures that have not been viewed for the number of days you set are automatically deleted, thereby freeing up storage space. You can overlay your site's watermark in the form of text or an image.
You can enable the option to allow users to use your "short" URL links using services like - bit.ly, yourls, is.gd, tinyurl.com, etc.
Sitemap generation (for Google, Bing...)
English is supported. And if the cookie function is enabled, then the user will not need to select a language the next time.
RSS Feed for the last 10 uploaded images.
MySQL database is not required.Support for .jpeg , .jpg , .bmp , .gif , .png and photoshop .psd format.
Checking uploaded files for MIME type and their extension.
We pick up
here (http://www.php-s.ru/download/click.php?id=75).
Enjoy.
Quote from: Newport on Aug 02, 2022, 07:33 AMWell, in order to be able to immediately share on Facebook, Instagram, and other social networks.
Did you mean this?
screen_89341.png
The author's site is no longer working, I will give a machine translation.
CF ImageHost.Script for organizing image hosting. Easy installation and control of photo hosting (sharing). With features such as preview generation, social media link generation for each individual image, image hosting.
Through the admin panel, you can get detailed data on traffic usage. A very important feature: pictures that have not been viewed for the number of days you set are automatically deleted, thereby freeing up storage space. You can overlay your site's watermark in the form of text or an image.
You can enable the option to allow users to use your "short" URL links using services like - bit.ly, yourls, is.gd, tinyurl.com, etc.
Sitemap generation (for Google, Bing...)
English is supported. And if the cookie function is enabled, then the user will not need to select a language the next time.
RSS Feed for the last 10 uploaded images.
MySQL database is not required.Support for .jpeg , .jpg , .bmp , .gif , .png and photoshop .psd format.
Checking uploaded files for MIME type and their extension.
We pick up here (http://www.php-s.ru/download/click.php?id=75).
Enjoy.
Quote from: _AnnA_ on Aug 02, 2022, 06:34 AMTry it. Let me know how it went.
Thank you very much, Anna.
Exactly what is needed.
The second script is also very useful.
Yes, there are several pre-existing scripts and libraries available that can help facilitate server uploads and generate links to the uploaded files. Here are a few suggestions:
1. FilePond: FilePond is a JavaScript library that provides an easy-to-use file upload experience. It handles all aspects of file uploading including drag-and-drop, image preview, and generating secure links to the uploaded files.
2. Dropzone.js: Dropzone.js is another popular JavaScript library for file uploads. It provides a simple and customizable drag-and-drop interface and supports features like automatic thumbnail generation and progress bars. It also offers options for generating links to the uploaded files.
3. Laravel: If you're open to using a PHP framework, Laravel provides an excellent solution for file uploads. It includes built-in support for handling file uploads, saving files to the server, and generating links to the uploaded files. Laravel's dоcumentation offers step-by-step instructions on how to implement these features.
These options provide varying levels of customization and coding requirements, but they all aim to simplify the process of server uploads and link generation. Take a look at their dоcumentation and choose the one that best fits your needs.
I'd suggest a simple PHP script using the built-in move_uploaded_file() function to handle file uploads and generate a shareable link. Here's a basic example:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
// Check if file already exists
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
// Check file size (limit to 5MB)
if ($_FILES["fileToUpload"]["size"] > 5000000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" && $imageFileType != "pdf" && $imageFileType != "txt") {
echo "Sorry, only JPG, JPEG, PNG, GIF, PDF, and TXT files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded.<br>";
echo "Share this link: <a href='" . $target_file . "' target='_blank'>" . $target_file . "</a>";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
}
?>