Jump to content

pleek

Members
  • Posts

    135
  • Joined

  • Last visited

Posts posted by pleek

  1. ok i found this code

     

    <script type="text/javascript">
    function changeText(){
    document.getElementById('boldStuff').innerHTML = 'Fred Flinstone';
    }
    </script>
    <p>Welcome to the site <b id='boldStuff'>dude</b> </p> 
    <input type='button' onclick='changeText()' value='Change Text'/>
    
    

     

    Now my question is how can i change that so i can input what i want the id "boldStuff" to say? I want to be able to enter in say my name, click "Change Text" and it change dude to my name.

     

    Thanks in advanced.

  2. ok so ive been searching the internet for almost an hour and i can't find anything. All i want is a paypal donation form that gets the users email, name, and how much they want to donate. Then it checks them out at paypal. Anybody know how to do this, or a site that has a tutorial on how to?

  3. ok so i have this function in my forum

     

    function hiliteItem($item) {
    $action = $_REQUEST['action'];
    $active = ' class="active_menu"';
    if (strtolower($item) == strtolower($action)) {
    	return $active;
    } elseif (strtolower($item) == "home" && $action == "") {
    	return $active;
    } 
    

     

    what it does is highlight the correct tab (the one currently being used). But sense the homepage is just index.php there is no "action" for it go get. This makes it spit out errors galore saying that "action" is undefined. Can this be edited so that if the "action" == "" it doesn't make an error? again this only a cures when the url is "index.php"

  4. ok so i have a working html script that changes the action of the form on the page.

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <HTML>
    <HEAD>
    <TITLE>Untitled</TITLE>
    <META NAME="GENERATOR" CONTENT="MAX's HTML Beauty++ 2004">
    </HEAD>
    <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
    function changeAction() {
    document.myform.action = "upload.php?FN=3DWORLD";
    }
    </SCRIPT>
    <BODY>
    
    <A HREF="javascript:changeAction()">change the action</A>
    
    <form name="myform" action="uploader.php" method="POST" enctype="multipart/form-data">
    Choose a file to upload: <input name="uploadedfile" type="file" /><br />
    <input type="submit" NAME="change" value="Upload File">
    </form>
    
    </BODY>
    </HTML>

     

    But when i expanded it and changed to php it doesn't work anymore. Any clue y? I have looked over the script at least 15 times and i can't find anything wrong.

     

    <?php
    echo'
    <HTML>
    <HEAD>
    <TITLE>Form</TITLE>
    <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
    function DWORLD() {
    document.myform.action = "uploader.php?FN=3DWORLD";
    }
    function 10yard() {
    document.myform.action = "uploader.php?FN=10yard";
    }
    function 1942() {
    document.myform.action = "uploader.php?FN=1942";
    }
    function 1943() {
    document.myform.action = "uploader.php?FN=1943";
    }
    function 720() {
    document.myform.action = "uploader.php?FN=720";
    }
    function 8eyes() {
    document.myform.action = "uploader.php?FN=8eyes";
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    <TABLE>
    <TR>
    <TD>';
    if (file_exists('Games/10yard.NES')) {
        echo '';
    }else{
    echo '<A HREF="javascript:10yard()">10-Yard Fight</A><BR>';
    }
    
    if (file_exists('Games/1942.NES')) {
        echo '';
    }else{
    echo '<A HREF="javascript:1942()">1942</A><BR>';
    }
    
    if (file_exists('Games/1943.NES')) {
        echo '';
    }else{
    echo '<A HREF="javascript:1943()">1943</A><BR>';
    }
    
    if (file_exists('Games/3DWORLD.NES')) {
    echo '';
    }else{
    echo '<A HREF="javascript:DWORLD()">3-D WorldRunner</A><BR>';
    }
    
    if (file_exists('Games/720.NES')) {
    echo '';
    }else{
    echo '<A HREF="javascript:720()">720°</A><BR>';
    }
    
    if (file_exists('Games/8eyes.NES')) {
    echo '';
    }else{
    echo '<A HREF="javascript:8eyes()">8 Eye\'s</A><BR>';
    }
    
    echo'
    </TD>
    <TD>
    <form name="myform" action="uploader.php" method="POST" enctype="multipart/form-data">
    Choose a file to upload: <input name="uploadedfile" type="file" /><br />
    <input type="submit" NAME="change" value="Upload File">
    </form>
    </TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>';
    
    ?>

  5. now that you explained that both checks are working. thanks a lot guys!!!!!

     

    <?php
    
    $target_path = "Games/";
    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
    $file = "3DWORLD.NES";
    
    if($_FILES['uploadedfile']['name'] == $file) {
    echo'the files are the same<BR>';
    }
    
    if ($_FILES['uploadedfile']['type'] == "application/octet-stream")
    {
    echo "the file is a .NES<BR>";
    }
    
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
        " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
    
    
    ?>
    

  6. i understand how to use var but i don't know how to check it with the file that is being uploaded.

     

    $filename = game.nes
    $filecheck = THE UPLOADED FILE NAME WITH EXTENSION
    
    if ( $filecheck != $filename) {
    echo' Only .nes games can be uploaded';
    }
    
    

     

    what i don't know is how to get the name and extension of the file that is being uploaded to set it to $filecheck.

     

    Now do you get where im stuck? and by "in the manual" do you mean the $_file link post earlier? cause when i tried $_FILES['userfile']['type'] i was told i was doing something wrong and not setting the var correctly.

  7. i tried the code you posted and i get the same results

    and as for "Why not just check the filename?" that would be fine as long as i can check the file name and extension. so like "if file = game.nes"

     

    Does the filename have to br a specific game? I am confused. The code I posted above will verify that the extension is .nes no matter the case. Is that not what you wanted? As far as verifying that the file is a true .nes and not just some text file I uploaded, you can check that octet stream, but yea. I am not sure how you would go about verifying that.

    To that, no the the filename does not have to be a specific game. I added your code to my script and it didn't work.

     

    Current code...

    <?php
    $target = "Games/";
    $target = $target . basename( $_FILES['uploaded']['name']) ;
    
    //This is our limit file type condition
    if (!preg_match("/.*\.nes$/i", $type))
    {
    echo "Only .NES files are allowed.<br>";
    echo "<pre>";
    print_r($_FILES);
    }
    
    //If everything is ok we try to upload it
    else
    {
    if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
    {
    echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
    }
    else
    {
    echo "Sorry, there was a problem uploading your file.";
    }
    }
    ?> 
    

     

    Once again, try using the correct variable name in your condition.  You're checking $_FILES['userfile']['type] and that doesn't exist.

     

    Um. ok then what should i check? I was going by what was posted earlier about $_file that linked me to http://us3.php.net/features.file-upload

  8. i tried the code you posted and i get the same results

     

    Only .NES files are allowed.
    
    Array
    (
        [uploadedfile] => Array
            (
                [name] => 3DWORLD.NES
                [type] => application/octet-stream
                [tmp_name] => /tmp/php7s7TE1
                [error] => 0
                [size] => 262160
            )
    
    )
    

     

    and as for "Why not just check the filename?" that would be fine as long as i can check the file name and extension. so like "if file = game.nes"

  9. make an upload form that submits to

    <?php
    echo "<pre>";
    print_r($_FILES);
    ?>

    and upload some files to it and see what they come up as.

     

    Scott.

     

    thank you for that, and your first post correctly told me the type

     

    Array
    (
        [uploadedfile] => Array
            (
                [name] => 3DWORLD.NES
                [type] => application/octet-stream
                [tmp_name] => /tmp/phpyQzpdv
                [error] => 0
                [size] => 262160
            )
    
    )
    
    

     

    so i changed my code to

     

    <?php
    $target = "Games/";
    $target = $target . basename( $_FILES['uploaded']['name']) ;
    
    //This is our limit file type condition
    if ($_FILES['userfile']['type'] != "application/octet-stream")
    {
    echo "Only .NES files are allowed.<br>";
    echo "<pre>";
    print_r($_FILES);
    }
    
    //If everything is ok we try to upload it
    else
    {
    if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
    {
    echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
    }
    else
    {
    echo "Sorry, there was a problem uploading your file.";
    }
    }
    ?> 
    

     

    but it still doesn't work. Any other suggestions?

  10. ok, i think that means try it. lol, i did and it didn't work. here's my upload script.

     

    <?php
    $target = "Games/";
    $target = $target . basename( $_FILES['uploaded']['name']) ;
    
    //This is our limit file type condition
    if ($uploaded_type != "application/x-nes-rom")
    {
    echo "Only .NES files are allowed.<br>";
    }
    
    //If everything is ok we try to upload it
    else
    {
    if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
    {
    echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
    }
    else
    {
    echo "Sorry, there was a problem uploading your file.";
    }
    }
    ?> 
    

     

    now what....

  11. ok, so i check out the swfupload and it was pretty cool. But not really what i need. So i did a little more google searching and i found this php code which does allow you to check the files extension before uploading. I can modify this to work but i need to know is it secure enough for an admin section in my script?

     

    form.php

    <form action="upload.php" method="post" ENCTYPE="multipart/form-data">
    File: <input type="file" name="file" size="30"> <input type="submit" value="Upload!">
    </form>
    

    upload.php

     

     <?php
    // ==============
    // Configuration
    // ==============
    $uploaddir = "uploads"; // Where you want the files to upload to - Important: Make sure this folders permissions is 0777!
    $allowed_ext = "jpg, gif, png, pdf"; // These are the allowed extensions of the files that are uploaded
    $max_size = "50000"; // 50000 is the same as 50kb
    $max_height = "100"; // This is in pixels - Leave this field empty if you don't want to upload images
    $max_width = "100"; // This is in pixels - Leave this field empty if you don't want to upload images
    
    // Check Entension
    $extension = pathinfo($_FILES['file']['name']);
    $extension = $extension[extension];
    $allowed_paths = explode(", ", $allowed_ext);
    for($i = 0; $i < count($allowed_paths); $i++) {
    if ($allowed_paths[$i] == "$extension") {
    $ok = "1";
    }
    }
    
    // Check File Size
    if ($ok == "1") {
    if($_FILES['file']['size'] > $max_size)
    {
    print "File size is too big!";
    exit;
    }
    
    // Check Height & Width
    if ($max_width && $max_height) {
    list($width, $height, $type, $w) = getimagesize($_FILES['file']['tmp_name']);
    if($width > $max_width || $height > $max_height)
    {
    print "File height and/or width are too big!";
    exit;
    }
    }
    
    // The Upload Part
    if(is_uploaded_file($_FILES['file']['tmp_name']))
    {
    move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
    }
    print "Your file has been uploaded successfully! Yay!";
    } else {
    print "Incorrect file extension!";
    }
    ?>

  12. ok sorry, here is the code im currently using. Just a generic code that works to upload any file up to 100kb to the "game" dir. Yes i know its not very safe but its only open to me right now.

     

    upload form

    <form enctype="multipart/form-data" action="uploader.php" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
    Choose a file to upload: <input name="uploadedfile" type="file" /><br />
    <input type="submit" value="Upload File" />
    </form>
    

     

    upload.php

    <?php
    
    $target_path = "Games/";
    
    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
    
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
        " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
    
    
    ?>
    

     

    And if you need javascript to do this that would be fine. This is what i need, i am using games as a generic term for what we're uploading...

     

    1. First you select the name of the game you want to upload - i select "bike_game" as my game.

    2. Then the upload form appears (optional).

    3. Then when you select browse you can only select/upload so i would only be able to upload "bike_game.exe"\

     

    if you still have questions please ask.

  13. Hello, i am designing a website for my own personal use but im having trouble with upload forms. I found out how to upload the a directory on my site but heres the problem. I need a form that when you select (from a drop down box) the name of the file to be uploaded, when you browes it will only let you upload the file with the exact name and extenction. So like if i want to upload only .jpg's and i select "game" from the menu. The form will only allow "game.jpg" to be uploaded.

     

    Thanks in advance,

    Pleek

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.