Jump to content

Search the Community

Showing results for tags 'download'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 18 results

  1. I want to backup mp3 files from a server folder to a local folder can this be done in php which is server side. I tried many scripts claiming to do this but all result in 'failed to open stream: No such file or directory' because the code is looking for the destination on the server, not the local directory. Here is an example that says it can be done. ini_set('display_errors',1); error_reporting(E_ALL); $source = "https://domain.com/2024-2021/path_to_file/test.mp3"; echo "src is ", $source; $destination = "C:/backup/2024-2021/Cpath_to_file/"; file_put_contents($destination, file_get_contents($source)); echo "OK"; This one also claims to 'force' the download $file = '/path/to/files/photo.jpg'; if (is_file($file)) { sendHeaders($file, 'image/jpeg', 'My picture.jpg'); $chunkSize = 1024 * 1024; $handle = fopen($file, 'rb'); while (!feof($handle)) { $buffer = fread($handle, $chunkSize); echo $buffer; ob_flush(); flush(); } fclose($handle); exit; } But has the same problem, in that it fails when opening the local folder to write the file, is there a way to do this?
  2. I have a download section in my index.php that I'd like to add a download counter to but have no idea how to accomplish this. The existing code works perfectly but I'd like to know how many times the file is downloaded. Would prefer not to use a database. <!-- DOWNLOAD --> <div id="download" class="stylized"> <div "myform"> <div class="container"> <div class="row"> <div class="download"> <br /><br> <h1><center>FoxClone Download Page</center></h1> <?php $files = glob('download/*.iso'); $file = $files[count($files) -1]; $info = pathinfo($file); $filename = basename($file); $filename = ltrim($filename,'/'); $md5file = md5_file($file); ?> <div class="container"> <div class="divL"> <h3>Get the "<?php echo "{$filename}";?>" file (approx. 600MB)</h3> <center> <a href="<?php echo "/{$file}";?>"><img src="images/button_get-the-app.png" alt=""></a> </center><br /> <h3 style="margin-bottom: 0.5rem;">The MD5sum for "<?php echo "{$filename}";?>" is "<?php echo "{$md5file}";?> Thanks in advance, Larry
  3. Hello guys i need to add php script for downloading mp4 and mp3 files on my website [redacted] any help i need the codes please.
  4. So I am creating a small file manager to manage uploaded files into a certain directory on my sever. I have created the attached code, but the issue is that when I click the download button, the webpage (html file) itself gets downloaded instead of the file in the directory that is supposed to be downloaded. Please note that there is no upload file type restrictions, so there are any file type you can imagine in this directory. I can't recognize the error in my code. Any help will be highly appreciated and that you in advance <html> <head> <title>My first PHP Page</title> </head> <body> <table border="1"> <?php $dir = 'uploads'; $files = scandir($dir); sort($files); $count = -1 ; foreach ($files as $file) { $v_download = "download_".$count; $v_delete = "delete_".$count; $v_rename = "rename_".$count; $fileName = $file; if ($file != '.' && $file != '..') { echo "<tr>"; echo "<td>"; echo $count; echo "</td>"; echo "<td>"; echo $file; echo "</td>"; echo "<td>"; echo "<form action='' method='post'><input type='submit' value='Download' name='".$v_download."'/></form>"; if(isset($_POST[$v_download])) { $filename = $_POST[$file]; header('Content-type: '.filetype($filename).'/'.pathinfo($filename, PATHINFO_EXTENSION)); header('Content-Disposition: attachment; filename="'.$filename.'"'); readfile('uploads/'.$filename); exit(); } echo "</td>"; echo "<td>"; echo "<form action='' method='post'><input type='submit' value='Delete' name='".$v_delete."'/></form>"; if(isset($_POST[$v_delete])) { // Your php delete code here echo "delete file : ".$file; } echo "</td>"; echo "<td>"; echo "<form action='' method='post'><input type='submit' value='Rename' name='".$v_rename."'/></form>"; if(isset($_POST[$v_rename])) { // Your php rename code here echo "rename file : ".$file; } echo "</td>"; echo "</tr>"; } $count++; } ?> </table> </body> </html> list.html
  5. I have a php application that serves pdf downloads. It works fine on all devices and browsers with one small but really annoying side-effect (edge-case for sure) When I look at my download logs anytime the download is triggered from Chrome on Android it is called twice! Bizarre behavior and I can't figure it out. Some background: The download is a pdf that get's created on the fly. All requests get processed through my index.php controller. I was serving the request with javascript via: window.open('export?file=something_to_inform_the_controller'); Works great in all browsers and devices but android chrome triggers this twice. So I got wise and though maybe a direct link would work better: <a target="_blank" href="http://mysite.com/export?file=abc123" download="file.pdf">DL link</a> or <a target="_blank" href="http://mysite.com/export?file=abc123">DL link</a> or <a target="_self" href="http://mysite.com/export?file=abc123" download="file.pdf">DL link</a> or <a target="_self" href="http://mysite.com/export?file=abc123">DL link</a> Nope, none of these flavors prevents android/chrome from double downloading. Then I researched my php header settings and tried: content-disposition: inline vs. content-disposition: attachment with no success Note, the download is logged when the controller processes the request for the download. I have duplicated download events for all downloads on android/chrome. It's strange that I have not found a solution online for this or maybe I'm overlooking something silly. Any ideas?
  6. Hello guys I'm blade and I love php I love to learn. Yesterday I found a site https://bitport.io where if you upload a torrent or magnet url it will download your file and able to view it online. I am wondering how did the downloading of files work and searching using magnet URL to download the torrent? Kindly guide me of what should I check or research about it. Thank you so much!
  7. Hi Guys I trying to download files and I have this error message, hopelly you guys can help me please Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 14 Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 15 Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 16 Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 17 Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 18 This is the code I use to force the download <?php include('core/inc/init.inc.php'); if(isset($_GET['file_id'])) { $file_id=(int)$_GET['file_id']; $file=mysql_query("SELECT file_name, file_expiry FROM files WHERE file_id=$file_id"); if(mysql_num_rows($file)!=1){ echo'Invalid file Id'; }else{ $row=mysql_fetch_assoc($file); if ($row['file_expiry']<time()){ echo'This file has expired'; }else{ $path="core/files/{$row['$file_name']}"; header('Content-Type:application/octet-stream'); header('Content-Description:File Transfer'); header('Content-Transfer-Encoding:binary'); header("Content-Disposition:attachment;filename=\"{$row['file_name']}\""); header('Content-Length:'.filesize($path)); readfile($path); } } } ?> Thank you for your help.....
  8. Hello, I want the user to get authenticated before file download starts Here is my code: <?php if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'Your request is cancelled'; exit; } else { //check $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] if (isset ($valid)) { //start download $path = './data/negative_seq_60.txt'; $type = "text/plain"; header("Expires: 0"); header("Pragma: no-cache"); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: pre-check=0, post-check=0, max-age=0'); header("Content-Description: File Transfer"); header("Content-Type: " . $type); header("Content-Length: " .(string)(filesize($path)) ); header('Content-Disposition: attachment; filename="'.basename($path).'"'); header("Content-Transfer-Encoding: binary\n"); readfile($path); // outputs the content of the file exit(); } else { //show error } } ?> But on clicking download link, I am getting the following error : " Undefined variable: valid at line no 9". Please help.
  9. Hi PHP freaks!! I have manage to make a script to upload file in database and its working. I will share to you the codes so for other viewers and readers to use also. if($result){ if($_FILES['LRCard']['name'] != ""){ $filename = $_FILES['LRCard']['name']; $ext = strrchr($filename,"."); $LRCardname = $student_id; $LRCardname .="_". $filename; if($ext ==".jpg" || $ext ==".jpeg" || $ext ==".JPG" || $ext ==".JPEG" || $ext ==".gif" || $ext ==".GIF"){ $size = $_FILES['LRCard']['size']; if($size > 0 && $size < 5000000){ $archive_dir = "LRCards"; $userfile_tmp_name = $_FILES['LRCard']['tmp_name']; if(move_uploaded_file($userfile_tmp_name, "$archive_dir/$LRCardname")){ /* if LRC is successfully uploaded then LRC is stored in database. */ mysql_query("update student_information set LRCard='$LRCardname' where student_id='$student_id'", $link_id); $flag = "success"; if(mysql_error()!=null){ die(mysql_error()); } } else{ if(file_exists('LRCard/' . $LRCardname)) { unlink('LRCards/' . $LRCardname); } rollbackData(); } } else{ if(file_exists('LRCards/' . $LRCardname)) { unlink('LRCard/' . $LRCardname); } rollbackData(); die("You can upload LRCard of 5 MB size only. Please, try again."); } } else{ if(file_exists('LRCards/' . $LRCardname)) { unlink('LRCards/' . $LRCardname); } rollbackData(); die("You can upload LRCard of .jpg, .jpeg, .gif extensions only. Please, try again. "); } } } else{ $flag="error"; } if($flag == "success"){ mysql_query(" COMMIT "); $flag="success"; if(mysql_error() != null){ die(mysql_error()); } } Now, my problem is how to make a Php script to DOWNLOAD this uploaded file considering the 1. file path 2. file name 3. file extension. 4. student_id (to determine the specific file from a specific student) My plan is to make a download button which hyperlink to download.php and after clicking that button the specified file to a specific student id will automatically be downloaded by the browser.
  10. What are the practical differences between PHPX.Y.Z's source download release, qa release, and snapshot release? I am trying to build my own PHP from source on Windows Server 2008 using Visual Studio 2013. I get to a point in the process as outlined in a step-by-step narrative where I am suppose to choose all my options, but the option to have the FPM enabled isn't in the list - but the folder is there. Is there a specific source variant that gives me everything - and I mean everything! - so I will get the FPM anyway - without the gnashing of teeth caused by having no instruction on what to do when something slightly different is needed than what the narrative lays out.
  11. Hi - we have been using google code to host our open source projects till now and they get a lot of downloads too.. Google code is going to stop offering downloads starting Jan 2014 and we want an alternate. We have enough bandwidth to host the download our self... but just need some help finding out the right too. the most important thing is that we need to offer direct downloads to our zip files... most of the scripts we find online are really in a manner that the download has to be router through php. is there a script of function out there that can do this job for us?
  12. I've set up code to allow users to purchase mp3 files. I keep the files in a non web-accessible directory and use a script that verifies that the user is logged in and has purchased the file before it lets them download it. Once the user has been validated it outputs the header specifying a file transfer and sends the file. The problem is that iPhone and iPad users are complaining that their devices won't download the file. It works for everybody else. Is there a fix for this? Some alternate way of doing this that would work on an Apple mobile device? This is the relevant part of the code if(file_exists($path)) { header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: " . $mm_type); header("Content-Length: " .(string)(filesize($path)) ); header('Content-Disposition: attachment; filename="'.basename($path).'"'); header("Content-Transfer-Encoding: binary\n"); readfile($path); // outputs the content of the file }
  13. Hi all, I need a code that downloads all PDF files of a URL (e.g. www.myurl.com)? I want to run this code on my localhost (WAMP). Thank You for you time.
  14. I've been having trouble with one of my download scripts i've been using for a while which prevents users from seeing the direct-link location of a file. It's a simple php script which has worked on and off on several servers in the past. I used to think that it "stopped" working because of an issue with my hosting account but now it's happening too often that I have to consider the script is doing something wrong and clogging something up on the server. So, first the script itself (relevent parts only, disregard syntax or undefined variables, assume its all there): <?PHP $file_name = "download.zip"; $filelocation = "$rowx[FILE_URL]"; //fetches the file url from mysql database. header("Content-type: application/octet-stream\n"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0\n"); header("Content-Transfer-Encoding: binary\n"); header("Content-disposition: attachment; filename=\"$file_name\"\n"); readfile("$filelocation"); ?> Simple, right? One thing the script never does is actually find the filesize and allow for a perctage download indicator. The download is always for an "unknown" size. This could be part of the problem. Also, I checked to make sure there was no mysql database issue (being open too long or whatnot) so i closed the connection at the end of the script. Problem persists. My host advised me to increase the memory limits and cache in the php.ini file. It did absolutely nothing. Recently, when the problem came back on a new server. The host told me to upgrade to a dedicated IP, which I went ahead and did.The problem DID go away around this time, but I can't attribute it to the dedicated IP because they (the host) were likley mucking around the server around the same time and could have been flushing cache's and any number of things so I can't say what fixed it temporarily. My suspicion is still that something in the script is causing a table on the server to fill up and perhaps its not being dumped as new data is being written, hence the terminated download. That's only a guess, however. I've been having this problem on and off for YEARS, so a big thanks in advance to anyone who can help even a little.
  15. Having a download issue need help 1)I used the script written below to download .doc,.docx,.pdf,.octetstream file but when i download a octetstream file it display's file data in browser itself mycode:- if(file_exists('./upload_resume/'.$f)) { header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.$f.'"'); echo file_get_contents('./upload_resume/'.basename($f)); ob_clean(); ob_end_flush(); $read=readfile('./upload_resume/'.basename($f)); exit; ?> <script type="text/javascript"> history.back(); </script> <?php } ?>
  16. Hello guys, I have a wordpress website wich supplies download links. What i want to do: When a user clicks o a download link (external sources) i want to redirect him to the same page (iframe) but i want to put some ads on top of the window. How can i do that ?
  17. I've tried three different attempts to force php to download. None of them are working correctly. Can anybody help me get this working? The text/garbage that displays on the screen looks like it was a zip opened in a text editor. I have also tried this http://stackoverflow...rbage-on-screen with no luck either First: Returns a page full of garbage $fid = $_GET['file']; $results = mysql_query("SELECT filename FROM files WHERE id=$fid"); if (mysql_numrows($results) == 0){ echo "<b>File not found</b>"; return; } $file = mysql_result($results,0,"filename"); $fileurl = 'http://url.com/files/'.$file; // Set headers header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=$fileurl"); header("Content-Type: application/zip"); header("Content-Transfer-Encoding: binary"); // Read the file from disk readfile($fileurl); exit(); Second: Returns same garbage (.zip file) $fid = $_GET['file']; $results = mysql_query("SELECT filename FROM files WHERE id=$fid"); if (mysql_numrows($results) == 0){ echo "<b>File not found</b>"; return; } $file = mysql_result($results,0,"filename"); $fileurl = 'http://url.com/files/'.$file; header('Content-Description: File Transfer'); header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="'.basename($fileurl).'"'); //<<< Note the " " surrounding the file name header('Content-Transfer-Encoding: binary'); header('Connection: Keep-Alive'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($fileurl)); readfile($fileurl); Third: Returns same garbage, but also alters page layout $fid = $_GET["file"]; $results = mysql_query("SELECT filename FROM files WHERE id=$fid"); if (mysql_numrows($results) == 0){ echo '<b>File not found</b>'; return; } $file = mysql_result($results,0,'filename'); $fileurl = "http://url.com/files/".$file; // Inform browser that this is a force-download header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); // Inform browser that data can be binary in addition to text header('Content-Disposition: attachment; filename='.basename($fileurl)); header('Content-Transfer-Encoding: binary'); // Inform browser that this page expires immediately so that an update to the file will still work. header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($fileurl)); // Push actual file. ob_clean(); flush(); readfile($fileurl); exit(); Any help, insight, direction, or links would be greatly appreciated. Thank you. On a side note there are .zip, .rar, and .txt files. Do i just add content type lines?
  18. I have a "save file" button for mp3 files on my site. I've never used the header() function before, so I'm not positive that I'm using it right here. It works perfectly on localhost. When I upload it to my web host it works, but it takes forever for the save dialog to appear. You click the save file button and nothing happens until 20+ seconds later, then the dialog appears. It seems that the browser is downloading the whole file before the save dialog appears, then after selecting a destination the download happens instantaneously. As I've said, I'm not too familiar with the header() function or how it works, so what can I do to pop up the save as dialog first? Here is the download.php <?php header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: public'); header('Content-Description: File Transfer'); header('Content-Type: application/force-download'); header('Content-Disposition: attachment; filename="'.basename($_GET['f']).'"'); header('Content-Transfer-Encoding: binary'); readfile($_GET["f"]); ?> Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.