SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Jan 2003
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry help with mysql and file upload

    HI,

    Can any one point me to a script. That stores file uploaded to a mysql database.

    Thanks

  2. #2
    SitePoint Guru Marc's Avatar
    Join Date
    Nov 2000
    Location
    New York
    Posts
    765
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know it's not what you're looking for, but Kevin's book has a chapter at the end describing exactly that (and it includes all the code for it).
    Marc Gugliuzza
    marc.gugliuzza.com



  3. #3
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    South-West UK
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just finished writing a complete set of scripts if you'd like them?

    Let me know and I can mail them to you.

  4. #4
    SitePoint Addict
    Join Date
    Jan 2003
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got a small file upload script but when I try uploading more than 1 MB it's not working why does any one know

  5. #5
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The limit might be set to 1MB.
    http://www.php.net/manual/en/function.ini-set.php has more on this, you might not be able if you are on a shared server to set this though.

  6. #6
    SitePoint Addict
    Join Date
    Jan 2003
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No it's not set
    ----------------------------------------

    This is the script

    ----------------------------------------------------
    <?php
    $dbx = @mysql_connect("localhost", "", "" );
    if (!$dbx) {
    echo( "<p>Unable to connect to the " .
    "database server at this time.</p>" );
    exit();
    }
    if (! @mysql_select_db("abc" ) ) {
    echo( "<p>Unable to locate the " .
    "database at this time.</p >" );
    exit();
    }
    ?>
    <HTML>
    <HEAD>
    <TITLE>CBN WORLD UPLOAD PAGE</TITLE>
    </HEAD>
    <BODY BGCOLOR="#ffffff">
    <?php

    require("setup.php" );
    if($doupload) {
    if($ADMIN[RequirePass] == "Yes" ) {
    if($password != "$ADMIN[Password]" ) {
    ?>
    <P><CENTER><B><FONT FACE="Verdana">Error</FONT></B></CENTER></P>
    <P><CENTER><TABLE WIDTH="450" BORDER="0" CELLSPACING="0"
    CELLPADDING="0">
    <TR>
    <TD WIDTH="100%" BGCOLOR="#000000">
    <TABLE WIDTH="450" BORDER="0" CELLSPACING="1" CELLPADDING="2">
    <TR>
    <TD COLSPAN="2" BGCOLOR="#ffffff">
    <FONT COLOR="#000000" SIZE="-1" FACE="Verdana">Invalid Password</FONT></TD>
    </TR>
    </TABLE></TD>
    </TR>
    </TABLE></CENTER></P>
    </BODY>
    </HTML>
    <?php
    exit();
    }
    }
    $num = 0;
    while($num < $ADMIN[UploadNum]) {
    $num++;
    $picture = "fileup$num"."_name";
    $picture1 = $$picture;
    $picture2 = "fileup$num";
    $picture3 = $$picture2;
    if($picture3 != "none" ) {
    $filesizebtyes = filesize($picture3);
    $ok = 1;
    if($filesizebtyes < 10) {
    $error .= "Error uploading (file size lower than 10 bytes) for file $num<BR>";
    $ok = 2;
    }

    if(file_exists("$ADMIN[directory]/$picture1" ) OR $ok == 2) {
    $error .="File name already exists for file $num<BR>";
    } else {
    $sql = "INSERT INTO image (file) Values ('$ADMIN[directory]/$picture1')";
    copy ($picture3, "$ADMIN[directory]/$picture1" );
    mysql_query($sql);
    $error .="File $num has been uploaded<BR>";
    }
    }
    }

    if(!$error) {
    $error .= "No files have been selected for upload";
    }

    ?>
    <P><CENTER><B><FONT FACE="Verdana">Status</FONT></B></CENTER></P>
    <P><CENTER><TABLE WIDTH="450" BORDER="0" CELLSPACING="0"
    CELLPADDING="0">
    <TR>
    <TD WIDTH="100%" BGCOLOR="#000000">
    <TABLE WIDTH="450" BORDER="0" CELLSPACING="1" CELLPADDING="2">
    <TR>
    <TD COLSPAN="2" BGCOLOR="#ffffff">
    <FONT COLOR="#000000" SIZE="-1" FACE="Verdana"><?php echo $error; ?></FONT></TD>
    </TR>
    </TABLE></TD>
    </TR>
    </TABLE></CENTER></P>
    <P><CENTER>&nbsp;</CENTER></P>
    <P><CENTER>&nbsp;</CENTER></P>
    <P><CENTER><FONT SIZE="-2" FACE="Verdana"><B>Powered by/B> <A HREF="<A href="http://www.phpscriptcenter.com/uploader.php">http://www.phpscriptcenter.com/uploader.php" TARGET="_blank">Uploader</A> Version 1.1</FONT></CENTER>
    </BODY>
    </HTML>
    <?php
    exit();
    } else {
    $num = 0;
    while($num < $ADMIN[UploadNum]) {
    $num++;
    $html .= "<TR>
    <TD WIDTH=\"25%\" BGCOLOR=\"#295e85\">
    <FONT COLOR=\"#ffffff\" SIZE=\"-1\" FACE=\"Verdana\">File $num/FONT></TD>
    <TD WIDTH=\"75%\" BGCOLOR=\"#ffffff\">
    <INPUT NAME=\"fileup$num\" TYPE=\"file\" SIZE=\"25\">
    </TD> ";
    }
    ?>
    <FORM ENCTYPE="multipart/form-data" ACTION="uploader.php" METHOD="POST">
    <P><CENTER><B><FONT FACE="Verdana">Upload</FONT></B></CENTER></P>
    <P><CENTER><TABLE WIDTH="450" BORDER="0" CELLSPACING="0" CELLPADDING="0">
    <TR>
    <TD WIDTH="100%" BGCOLOR="#000000">
    <TABLE WIDTH="450" BORDER="0" CELLSPACING="1" CELLPADDING="2">
    <TR>
    <TD COLSPAN="2" BGCOLOR="#295e85">
    <B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Select Files</FONT></B></TD>

    </TR><?php echo $html; ?>
    </TABLE></TD>
    </TR>
    </TABLE></CENTER></P>
    <?php
    if($ADMIN[RequirePass] == "Yes" ) {
    ?>
    <P><CENTER><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
    <TR>
    <TD WIDTH="100%" BGCOLOR="#000000">
    <TABLE WIDTH="300" BORDER="0" CELLSPACING="1" CELLPADDING="2">
    <TR>
    <TD WIDTH="33%" BGCOLOR="#295e85">
    <B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Password/FONT></B></TD>
    <TD WIDTH="67%" BGCOLOR="#ffffff">
    <INPUT NAME="password" TYPE="password" SIZE="25">
    </TD>
    </TR>
    </TABLE></TD>
    </TR>
    </TABLE></CENTER></P>
    <?php
    }
    ?>
    <P><CENTER><INPUT NAME="doupload" TYPE="submit" VALUE="Upload Files"></CENTER></FORM>
    <P><CENTER>&nbsp;</CENTER></P>
    <P><CENTER>&nbsp;</CENTER></P>
    <P><CENTER><FONT SIZE="-2" FACE="Verdana"><B>Powered by/B> <A HREF="<A href="http://www.phpscriptcenter.com/uploader.php">http://www.phpscriptcenter.com/uploader.php" TARGET="_blank">Uploader</A> Version 1.1</FONT></CENTER>
    </BODY>
    </HTML>
    <?php
    exit();
    }

    ?>

    I hope anyone of you can help me

  7. #7
    SitePoint Addict
    Join Date
    Jan 2003
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With the above script when I try uploading a file that is big this is the error it gives

    No files have been selected for upload

    Even though I select the file it gives the error


Bookmarks

Posting Permissions

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