Results 1 to 6 of 6

Thread: Code Help !!! *RESOLVED*

  1. #1

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Code Help !!! *RESOLVED*

    I have a bad problem with the following code (mainly the fact that it doesn't load)...

    Please Help -

    PHP Code:
    <?php
    $extlimit 
    "yes"//Do you want to limit the extensions of files uploaded
    $limitedext = array(".gif",".jpg",".png",".jpeg",".Gif",".JPG"); //Extensions you want files uploaded limited to.
    $sizelimit "yes"//Do you want a size limit, yes or no?
    $sizebytes "15000"//size limit in bytes
    $dl "/Uploaded/"//url where files are uploaded
    $absolute_path "Http://scottsserver.hopto.org/Uploaded/"//Absolute path to where files are uploaded
    $websiteurl "http://scottsserver.hopto.org/"//Url to you website
    $websitename "Scotts Server";

    switch(
    $action) {
    default:
    echo
    "
    <html>
    <head>
    <title>Upload Or Download</title>
    </head>
    <body>
    <a href=
    $PHP_SELF?&action=upload>Upload File</a>
     <a href=
    $PHP_SELF?&action=download>Download File</a>
     <a href=
    $websiteurl>Return to $websitename</a>
    <br><br>
    Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
    </body>
    </html>"
    ;
    break;
    case 
    "download":
    echo 
    "
    <html>
    <head>
    <title>File Download</title>
    </head>
    <body><a href=
    $PHP_SELF?action=upload>Upload File</a> <a href=$websiteurl>Return to $websitename</a>";
    $list "<table width=700 border=1 bordercolor=#000000 style=\"border-collapse: collapse\">";
    $list .= "<tr><td width=700><center><b>Click To Download</b></center></td></tr>";
    $dir opendir($absolute_path);
    while(
    $file readdir($dir)) {
    if ((
    $file != "..") and ($file != ".")) {
    //Download files with spaces fix by Kokesh
    $list .= "<tr><td width=700><a href='$dl/$file'>$file</a></center></td></tr>";
    }
    }
    $list .= "</table>";
    echo 
    $list;
    echo
    "
    <br><br>
    Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
    </body>
    </html>"
    ;
    break;

    case 
    "upload":
    echo
    "
    <html>

    <head>
    <title>File Upload</title>
    </head>

    <body>

    <form method=POST action=
    $PHP_SELF?action=doupload enctype=multipart/form-data>
    <p>File to upload:<br>
    <input type=file name=file size=30>
    <p><button name=submit type=submit>
    Upload
    </button>
    </form>
    <br><br>
    Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
    </body>

    </html>"
    ;
    break;


    //File Upload
    case "doupload":
    $dir "dir";
    if (
    $file != "") {

    if (
    file_exists("$absolute_path/$file_name")) {
    die(
    "File already exists");
    }

    if ((
    $sizelimit == "yes") && ($file_size $sizebytes)) {
    die(
    "File is to big. It must be $sizebytes bytes or less.");
    }

    $ext strrchr($file_name,'.');
    if ((
    $extlimit == "yes") && (!in_array($ext,$limitedext))) {
    die(
    "The file you are uploading doesn't have the correct extension.");
    }

    @
    copy($file"$absolute_path/$file_name") or die("The file you are trying to upload couldn't be copied to the server");

    } else {
    die(
    "Must select file to upload");
    }
    echo 
    "
    <html>
    <head>
    <title>File Uploaded</title>
    </head>
    <body>"
    ;
    echo 
    $file_name." was uploaded";
    echo 
    "<br>
    <a href=
    $PHP_SELF?action=upload>Upload Another File</a>
    <a href=
    $PHP_SELF?action=download> Download File</a>
    <a href=
    $websiteurl> Return to $websitename</a><br><br>
    Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
    </body>
    </html>"
    ;
    break;

    }
    ?>
    It appears to be a problem with the Echo() functions, although i am not really sure !
    Last edited by thegreatone; Jul 9th, 2004 at 07:41 AM.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    First off..... what does it do or not do? What "seems" to be wrong?

    Secondly, your default switch case is in the wrong spot. It should be the LAST item in the list, not the first.....

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Wink

    Well, firstly it doesn't display anything in the echo()'s after the Switch part

    (o yeah, i'm a total newbie to this)

    Where should the switch go then ?

    This will more than likely solve the problem !

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    it should be like this:
    Code:
    switch ($Item) {
       'Step1':
       'Step2':
       'Step3':
       default:
    }
    What you have is this:
    Code:
    switch ($Item) {
       default:
       'Step1':
       'Step2':
       'Step3':
    }

    The default: says, if I got here, and there were no matches, run me. Since it is the first thing, it should always run, which isn't what you want.

    Now, I notice that you never set $action anywhere.... I understand it's supposed to be pass as part of the form, BUT, it looks like you assume that GLOBALS is on.... which it may not be... and it is dangerous to be on.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    PHP Uploader Downloader
    Does that make anyone else giggle? Does the program download an uploader?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333
    lol, no, and now i realise the problem, sorry... thanks for the help !

    (And by the way Globals is actually on (unsafe but easy for me ! )

Posting Permissions

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



Click Here to Expand Forum to Full Width