خرید بک لینک
Hello, I'm working on making my first basic upload and download web app and was able to push and upload file from the target '$path' and tagging 'md5', but I'm now not sure how to retrieve it back via download link or some sort.

Here's my upload.php:
PHP Code:

<?php
include("coection.php");

if (isset(
$_POST['submit']))
{

$name mysqli_real_escape_string($co$_POST['name']);
$description mysqli_real_escape_string($co$_POST['description']);

if (
$name == '' || $description == '' )
{

$error 'ERROR: Please fill required fields!';

renderForm($name$description);
}
else
{

if(isset(
$_FILES['filefield'])){
$file=$_FILES['filefield'];
$upload_directory='uploads/';
$ext_str "gif,jpg,jpeg,mp3,tiff,bmp,doc,docx,ppt,pptx,txt,pdf";
$allowed_extensions=explode(',',$ext_str);
$max_file_size 2097152;
$ext substr($file['name'], strrpos($file['name'], '.') + 1);
if (!
in_array($ext$allowed_extensions) )
{

echo 
'<script language="javascript">';
echo 
'alert("only gif,jpg,jpeg,png,mp4,tiff,bmp,doc,docx,ppt,pptx,txt,pdf files allowed to upload")';
echo 
'</script>';
exit(); 
}

$path=md5(microtime()).'.'.$ext;

if(
move_uploaded_file($file['tmp_name'],$upload_directory.$path)){

    
$filefield $_FILES["filefield"]["name"];
    
$path $path."/".$filefield;
$query "INSERT INTO `item`(`name`, `description`, `path`) VALUES ('$name','$description','$path')";
$result mysqli_query($co$query);
 if(
$result)
    {
    echo 
'<script language="javascript">';
    echo 
'alert("Item created!")';
    echo 
'</script>';      
    exit();
}   
}
}
}
}
?>

I created a separate form to echo the (name, description, path) content of DB with respect to its 'id' and the path, presumably sort of "download link". My retrieve.php:

PHP Code:

<?php
function renderForm($id$name$description$path$error)
{
?>
<html>
<body>
<div style="background-color:lightblue">
<strong>Name: </strong><?php echo $name?><br/>          
<strong>Description: </strong><?php echo $description?><br/>

<strong>Attachment: </strong><?php echo $path?><br/>         <!--how to download?-->:confused:

</div>
</body>
</html>

<?php
include("coection.php");

$id $_GET['id'];
$result mysqli_query($co"SELECT * FROM order.item WHERE id=$id")
or die(
mysqli_error());
$row mysqli_fetch_array($result);

if(
$row)
{
$name $row['name'];
$description $row['description'];
$path $row['path'];

renderForm($id$name$description$path'');
}
?>

Click image for larger version. 

Name:	Capture.JPG 
Views:	0 
Size:	23.3 KB 
ID:	17973

How can I make it clickable to download? or any other way to achieve downloading/retrieving it (reversing the MD5 tag)? Appreciated the help guys!
Attached Thumbnails
Click image for larger version. 

Name:	Capture.JPG 
Views:	N/A 
Size:	23.3 KB 
ID:	17973  

برچسب: نویسنده: آیلین رضوانی تاريخ: سه شنبه 6 شهريور 1397 ساعت: 7:47

صفحه بندی