Jump to content

Having download problem at my site


Panta
 Share

Recommended Posts

Please am new with php and I just uploaded my first site and in that my site I do encounter two problems that I don't see when using my local server.the first one is the main problem is that I have some tutorials I wish that people can download.in my local server if I try to download it will. Downlod.but now on the live server if I try to downlod it will just display a lot of code on the page ,and these code will come with numbers and alphabet.I guess there is somtin I ve not done write.plz I need help so that materials can be downloaded.the site is http://avatconcepts.com.ng/freedownloads.php

Link to comment
Share on other sites

I'd need to see some PHP code to be able to help. It looks like your website is sending a header and refreshing to the same 'downloads' page. Maybe an 'else' clause in your code keeps executing? Most likely will be a path issue I reckon, but of course that is only a pure guess. Regards, Lab.

Link to comment
Share on other sites

freedownlods.php <?php include('header.php') ;?> <div id="content"> <div class="post" id="post-12"> <h1 > Free Rendering Materials</h1> <div class="entry"> <div class="featured-image"> </div> <p class="url" > <p class="style3"> <strong>Revit</strong></p> <ol> <li> Click here to Download <a href="download.php?file=revit/79-ceilings-an-introduction-to-revit-ceilings.pdf">Revit Ceilings</a> </li> <li>Click here to Download <a href="download.php?file=revit/Revit_2011_to_ATL3_Win32.zip">Revit 2010 to Artlantics 3.0 plugin</a> </li> </li> </ol> <p class="style3"><strong> 3D max</strong></p> <ol> <li>Click here to Download <a href="">Max Cars</a></li> <li>Click here to Download <a href="">Max Tutorials</a> </li> </ol> <p class="style3"><strong> Shaders and Billboards</strong> </p> <ol> <li>Click here to Download <a href="">Raster Images</a> </li> <li>Click here to Download <a href="">Shaders</a></li> </ol> <p class="style3"><strong> Artlantics</strong></p> <ol> <li>Click here to Download <a href="download.php?file=artlantics/billboards.rar">Billboard and Shaders</a></li> <li>Click here to Download <a href="download.php?file=artlantics/artlantis_tutorial_script.pdf">Artlantics Tutorial</a></li> <li> Click here to Download <a href="">Artlantics Objects</a> </li> </ol> <strong style="color:#F00">Total</strong> <strong style="color:#F00">Site downloads <?php $fp=fopen("downloads.txt","r");$count=fgets($fp,1024);echo $count;?></strong><?php include('footer.php');?>End of freedownload.phpdownload.php$file_directory = "files"; //Name of the directory where all the sub directories and files exists$file = $_GET['file']; //Get the file from URL variable$file_array = explode('/', $file); //Try to seperate the folders and filename from the path$file_array_count = count($file_array); //Count the result$filename = $file_array[$file_array_count-1]; //Trace the filename$file_path = dirname(__FILE__).'/'.$file_directory.'/'.$file; //Set the file path w.r.t the download.php... It may be different for u.if(file_exists($file_path)) {header("Content-disposition: attachment; filename={$filename}"); //Tell the filename to the browser header('Content-type: application/octet-stream'); //Stream as a binary file! So it would force browser to download readfile($file_path); //Read and stream the file$site="freedownloads.php";include('count.php');//including download countsheader('Refresh: 2; URL='.$site);}else { echo "Sorry, the file does not exist! Please check the file in the directory";}}?>End of download.php

Link to comment
Share on other sites

Don't send a refresh header, when you're sending a file to download only send headers for downloading the file. The refresh header would also cause an error if output buffering is not enabled, which would corrupt the file data. I'm not sure exactly what the issue is because it asks me to sign in when I try to download a file. Your download script isn't very secure though, someone could use that to download any file on your server that PHP has permission to access. You aren't validating the file path to make sure that they are only downloading files within a certain directory. It would be a matter of trial and error to figure out the path to use to download anything on your server, including your PHP code or things like /etc/passwd if PHP has access to read that file.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...