Download.php Blank Page
Results 1 to 4 of 4

Thread: Download.php Blank Page

  1. #1
    Junior Member
    Join Date
    Sep 2014

    Download.php Blank Page

    Hiya guys

    I have a upload and down script, the upload works perfectly but the download displays a blank page with no files or errors

    PHP Code:
            <form method="post" enctype="multipart/form-data">
                <table width="350" border="0" cellpadding="1"
                       cellspacing="1" class="box">
                        <td>please select a file</td></tr>
                            <input type="hidden" name="MAX_FILE_SIZE"
                            <input name="userfile" type="file" id="userfile"> 
                        <td width="80"><input name="upload"
                                              type="submit" class="box" id="upload" value=" Upload "></td>

    if (isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) {
    $fileName $_FILES['userfile']['name'];
    $tmpName $_FILES['userfile']['tmp_name'];
    $fileSize $_FILES['userfile']['size'];
    $fileType $_FILES['userfile']['type'];
    $fileType = (get_magic_quotes_gpc() == mysql_real_escape_string(
    $_FILES['userfile']['type']) : mysql_real_escape_string(
    $fp fopen($tmpName'r');
    $content fread($fpfilesize($tmpName));
    $content addslashes($content);
        if (!
    get_magic_quotes_gpc()) {
    $fileName addslashes($fileName);
    $con mysql_connect('localhost''username''password') or die(mysql_error());
    $db mysql_select_db('company'$con);
        if (
    $db) {
    $query "INSERT INTO upload (name, size, type, content ) " .
    "VALUES ('$fileName', '$fileSize', '$fileType', '$content')";
    mysql_query($query) or die('Error, query failed');
    "<br>File $fileName uploaded<br>";
        } else {
    "file upload failed";
    and download.php

    PHP Code:


    // very basic check to see if user is logged in
    // kill the script display warning.
    die('Unauthorised accessed. You must be logged in to access this file');

    // Has a file id been passed? 
    if(isset($_GET['upid']) && ctype_digit($_GET['upid']))
    // fetch the file where the upid matches
    $result mysql_query('SELECT name, type, size, content FROM upload WHERE upid='.intval($_GET['upid']));

    // query executed ok
    // get the files details
    list($name$type$size$content) = mysql_fetch_row($result);

    // present file for download
    header("Content-length: $size");
    header("Content-type: $type");
    header("Content-Disposition: attachment; name=$name");

  2. #2
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Kansas City area
    Welcome to PHPBuilder! To start off, some general notes:

    As for your issue... how much debugging have you done? The code you posted above has three decisions; if the body of the page is truly empty, that would suggestion that the first decision was false. However, what about the two that follow?

  3. #3
    Junior Member
    Join Date
    Sep 2014
    Hi, I just figure it out, I forgot to add the connection to database lol. Working now

    However, are you able to help add a username field to the upload form, as I want to add a username and submit this at same time as the file?

    Yes my programming skills are learnt from little guides and youtube and majorly outdated. I have a course coming up at end of the month to do PDO, so I will rebuild my site once completed

  4. #4
    Junior Member
    Join Date
    Sep 2014

    I got it working a few mins ago I stupidly forgot to add a connection to the Dbase working now though

    I'm doing a course at the end of this month for PDO so once completed I hope to rebuild what I have at the moment.

    Are you able to shed any light on how to add a username field to the upload.php code above? At the minute, it only uploads a file, and I would like to add a username field and upload the file at the same time

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts