Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 3 123 LastLast
Results 1 to 10 of 22
  1. #1
    Join Date
    Oct 2005
    Location
    Spain, Valencia
    Posts
    20,492
    Tokens
    3,575
    Habbo
    GoldenMerc

    Latest Awards:

    Default What would be the code for

    Say if i wanted just on file name uploaded and not to allow any other file names what would it be, Say i wanted
    Banner1.png
    Banner2.png

    What would be the code to make it so only they could be uploaded, And once uploaded if i wanted to re-upload banner1.png say a updated one it automatically overwrites it.
    Ross

  2. #2
    Join Date
    Jun 2008
    Location
    Manchester
    Posts
    766
    Tokens
    0

    Default

    Files are automatically overwritten.
    PHP Code:
    if($name != "banner1.jpg" || $name != "banner2.jpg")
    {
    die(
    "File name not allowed");

    That should work if there are only one or two names. If there are more then it would probably be a better idea to check with MySQL.

  3. #3
    Join Date
    Oct 2005
    Location
    Spain, Valencia
    Posts
    20,492
    Tokens
    3,575
    Habbo
    GoldenMerc

    Latest Awards:

    Default

    PHP Code:
    <?php require('head.php');

    if(!
    $_GET["upload"])
    {
    echo(
    '

    <form action="?upload=upload" method="post" enctype="multipart/form-data">
    <div align="center">
    Please Choose a file to upload...<br />
    <input type="file" name="file" /><br /><br />
    <input type="submit" value="Upload File" />
    </div>
    </form>

    '
    );
    }
    else
    {
    $filename 'uploads/'.$_FILES["file"]["name"].'';
        if(!
    file_exists($filename))
        {
        
    move_uploaded_file($_FILES["file"]["tmp_name"],$filename);

    $filesize getimagesize("$filename");

    if(
    $filesize[0]<=53 AND $filesize[1]<=53)
    {
        echo(
    'Your File URL<br /><input type="text" size="50" value="http://www.hhgs.net/radiodjpanel/'.$filename.'" />');
    }
    else
    {
    unlink("$filename");
    echo(
    'Files must be the dimensions 53*453 or less!');
    }
        if(
    $name != "banner1.jpg" || $name != "banner2.jpg")
    {
    die(
    "File name not allowed");
    }  
    ?>
    So that would work correct?

  4. #4
    Join Date
    Jun 2008
    Location
    Manchester
    Posts
    766
    Tokens
    0

    Default

    Quote Originally Posted by HHGS.Net View Post
    PHP Code:
    <?php require('head.php');

    if(!
    $_GET["upload"])
    {
    echo(
    '

    <form action="?upload=upload" method="post" enctype="multipart/form-data">
    <div align="center">
    Please Choose a file to upload...<br />
    <input type="file" name="file" /><br /><br />
    <input type="submit" value="Upload File" />
    </div>
    </form>

    '
    );
    }
    else
    {
    $filename 'uploads/'.$_FILES["file"]["name"].'';
        if(!
    file_exists($filename))
        {
        
    move_uploaded_file($_FILES["file"]["tmp_name"],$filename);

    $filesize getimagesize("$filename");

    if(
    $filesize[0]<=53 AND $filesize[1]<=53)
    {
        echo(
    'Your File URL<br /><input type="text" size="50" value="http://www.hhgs.net/radiodjpanel/'.$filename.'" />');
    }
    else
    {
    unlink("$filename");
    echo(
    'Files must be the dimensions 53*453 or less!');
    }
        if(
    $name != "banner1.jpg" || $name != "banner2.jpg")
    {
    die(
    "File name not allowed");
    }  
    ?>
    So that would work correct?
    No,

    PHP Code:
    <?php require('head.php');

    if(!
    $_GET["upload"])
    {
    echo(
    '

    <form action="?upload=upload" method="post" enctype="multipart/form-data">
    <div align="center">
    Please Choose a file to upload...<br />
    <input type="file" name="file" /><br /><br />
    <input type="submit" value="Upload File" />
    </div>
    </form>

    '
    );
    }
    else
    {
    $name=$_FILES["file"]["name"]
    $filename 'uploads/'.$name.'';
        if(
    $name == "banner1.jpg" || $name =="banner2.jpg")
        {
        
    move_uploaded_file($_FILES["file"]["tmp_name"],$filename);

    $filesize getimagesize("$filename");

    if(
    $filesize[0]<=53 AND $filesize[1]<=53)
    {
        echo(
    'Your File URL<br /><input type="text" size="50" value="http://www.hhgs.net/radiodjpanel/'.$filename.'" />');
    }
    else
    {
    unlink("$filename");
    echo(
    'Files must be the dimensions 53*453 or less!');
    }
    }
    else
    {
    echo 
    "File name not allowed";
    }

  5. #5
    Join Date
    Oct 2005
    Location
    Spain, Valencia
    Posts
    20,492
    Tokens
    3,575
    Habbo
    GoldenMerc

    Latest Awards:

    Default

    Parse error: syntax error, unexpected T_VARIABLE in /home/hhgsnet/public_html/radiodjpanel/ibanner.php on line 20
    Doesn't seem to be right.

  6. #6
    Join Date
    Jun 2008
    Location
    Manchester
    Posts
    766
    Tokens
    0

    Default

    Uhh, I forgot a semicolon after
    PHP Code:
    $name=$_FILES["file"]["name"

  7. #7
    Join Date
    Oct 2005
    Location
    Spain, Valencia
    Posts
    20,492
    Tokens
    3,575
    Habbo
    GoldenMerc

    Latest Awards:

    Default

    Thats line 19, Its line 20...

  8. #8
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    This should work:

    change (this is line 20)
    PHP Code:
    $filename 'uploads/'.$name.''
    to
    PHP Code:
    $filename 'uploads/{$name}'

  9. #9
    Join Date
    Jun 2008
    Location
    Manchester
    Posts
    766
    Tokens
    0

    Default

    Quote Originally Posted by HHGS.Net View Post
    Thats line 19, Its line 20...
    Well the semicolon has to be there and I can't see anything wrong with line 20. Try removing the
    Code:
    .''

  10. #10
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by HHGS.Net View Post
    Thats line 19, Its line 20...
    The missing semicolon on line 19 would cause it to say there's an error on line 20.

Page 1 of 3 123 LastLast

Posting Permissions

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