justinsg Posted September 2, 2008 Share Posted September 2, 2008 I have just built a upload and download script. The purpose is to download a file from a URL to the local server giving it a unique id, and then provide a download link to the user to then download that file by giving their id. When I go to download from the link that outputs, or even from the server's root folder where the file is stored, all i get is a link to the hosting server's advertising site. The server link is, http://phpdl.freehostia.com/ Script contents: <html> <head> <title>Download a URL</title> <link href="style.css" rel="stylesheet" type="text/css"></head> <body> <h1>LoadTunnel</h1> <hr align="center" style="width: 100%; height: 2px;"> <br> <form action="" method="post" name="download" id="download"> <table border=1 align=left bordercolor="#000000"> <tr> <th colspan=3>Download a URL</th> </tr> <tr> <td width="65">URL</td> <td colspan="2"><input type="text" name="url" size=70 value="<?php if (isset($_POST['url'])) {echo $_POST['url'];} ?>"></td> </tr> <tr> <td>Block read</td> <td width="141"><input type="text" name="block" size=10 value="<?php if (isset($_POST['block'])) {echo $_POST['block'];} ?>"> mb</td> <td width="290">(default is 1mb)</td> </tr> <tr> <td> </td> <td colspan="2"><input type="submit" value="Download" id=t> <input type="reset" id=t> <input name="dl" type="hidden" id="dl" value="1"> </td> </tr> </table> </form> <p><br> </p> <p> </p><p> </p> <br><br><small> <?php #------------------------------------------------------------------ # Php script : upload_url.php # Description : upload from url to your host # Corrected version author : Alex TR # Original author : Do Duy Cop - [email protected] # Corrected on : 4/19/2005-00:24 AM # Modify : 9/21/2003-8:03 PM #------------------------------------------------------------------ #------------------------------------------------------------------ # function name : upload_url # @url : url of file want copy # @save_to : path of file will be save # @over_write : over_write=0: if exist file(save_to) then do nothing # @$block_read : default is 1048576 bytes ( = 1 MB) #------------------------------------------------------------------ if ($_POST['url']) { #------------------------------------------------------------------ if (!isset($_POST['block'])) { $block_read = $_POST['block'] * 1048576; } else { $block_read = 1048576; } $url = $_POST['url']; echo('</small><i>Checking URL...</i><br /><small>'); if(!$fr = fopen($url,'rb')) { echo('</small><i>URL cannot be read!<br><br><b></i>Try Again. If the problem persists<br>this must be a server error<br></b></i><small>'); $stop = 1; } if ($stop != 1) { echo('</small><i>Creating Output...<br>Reading Data...</i><br></small>'); $code = str_pad(rand(111111, 999999), 6, "0", STR_PAD_LEFT); while(is_file($code)) { $code = str_pad(rand(111111, 999999), 6, "0", STR_PAD_LEFT); } $file = "userfiles/$code.urldat"; echo("</small><i>Writing Data...</i><br><small>"); if(!$fw = fopen($file,"wb")) { echo('</small><i>Data Write Failed!<br><br><b>Please Try Again</b></i><small>'); $stop2 = 1; } if ($stop2 != 1 && $stop != 1) { $count_loop = 0; while(!feof($fr)) { $data = fread($fr,$block_read); if($len = strlen($data)) { $result .= (($len == fwrite($fw,$data,$len)) ? 'W' : 'E'); } if(($count_loop++ % 56) == 55) { $result .= "<br>"; } } echo("</small><i>Closing Files...</i><br><small>"); fclose($fr); fclose($fw); flush(); echo("</small><i>Clearing Buffer...<br>Finished!<br><br></i><b>Retrieval Code: </b>$code<small>"); } } } if($_POST['code']){ $show=1; $key = $_POST['code']; if (is_file("userfiles/$key.urldat")) { $userlink = "<a href=\"userfiles/$key.urldat\">Right-Click > Save Link As...</a>"; } else { $userlink = "Invalid Retrieval Code!"; } } ?> </small> <br><br><br><br><br> <hr align="center" style="width: 100%; height: 2px;"><br> <form action="" method="post" name="retrive" id="retrive"> <table border=1 align=left bordercolor="#000000"> <tr> <th colspan=3>Retrive a File on this Server</th> </tr> <tr> <td width="65">Code</td> <td width="431" colspan="2"><input type="text" name="code" size=70></td> </tr> <tr> <td> </td> <td colspan="2"><input name="get" type="submit" id=t value="Get Link"> <input name="retrive" type="hidden" id="retrive" value="1"></td> </tr> <tr> <?php if ($show == 1) { print "<td>URL </td><td colspan=\"2\">$userlink </td>"; } ?> </tr> </table> </form> <br> <p> </p> <p> </p> <p> </p> <p><br> </p> <hr align="center" style="width: 100%; height: 2px;"><br> <table width="752" border="0" align="left"> <tr> <td width="256" align="center"><strong>Version: </strong>1.0</td> <td width="241" align="center"><strong>Author: </strong>Justin S.</td> <td width="241" align="center"><a href="login/?go=logout">Logout of: <?php print $_SESSION['uname']; ?></a></td> </tr> </table> <br> <br> </body> </html> What is happening? and how do I fix this? It works fine on my home server (WAMP) on WinXP Thanks Justinsg Link to comment https://forums.phpfreaks.com/topic/122304-download-upload-script/ Share on other sites More sharing options...
Alphamonkey Posted September 2, 2008 Share Posted September 2, 2008 Forbidden You don't have permission to access / on this server. Link to comment https://forums.phpfreaks.com/topic/122304-download-upload-script/#findComment-631561 Share on other sites More sharing options...
justinsg Posted September 2, 2008 Author Share Posted September 2, 2008 try http://dltunnel.100webspace.net/ Link to comment https://forums.phpfreaks.com/topic/122304-download-upload-script/#findComment-631564 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.