Web Analytics Made Easy -
StatCounter Uploading not working - CodingForum

Announcement

Collapse
No announcement yet.

Uploading not working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Uploading not working

    I have this code:

    PHP Code:
    <form action="/index.php?page=site_add" method="post">
        <table class="box">
            <thead>
                <tr>
                    <th colspan="2">Add Your Schematic</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Schematic Name:</td>
                    <td>
                        <input type="text" class="input" name="site_name" value="" />
                        <img src="/images/info.png" class="tooltip" title="The name of your schematic/build." />
                    </td>
                </tr>
                <tr>
                    <td>Your Schematic:</td>
                    <td>
                        <input name="site_url" type="file" />

    <?php
     $target 
    "schematics/"
     
    $target $target basename$_FILES['site_url']['name']) ; 
     
    $ok=1
     if(
    move_uploaded_file($_FILES['site_url']['tmp_name'], $target)) 
     {
     echo 
    "The file "basename$_FILES['site_url']['name']). " has been uploaded";
     } 
    ?>
                        <img src="/images/info.png" class="tooltip" title="The Schematic of your uploading..." />
                    </td>
                </tr>
                <tr>
                    <td>Version:</td>
                    <td>
                        <input type="text" class="input" name="site_banner" value="" />
                        <img src="/images/info.png" class="tooltip" title="Include your schematic version." />
                    </td>
                </tr>
                <tr>
                    <td>Schematic Description:</td>
                    <td>
                        <textarea class="textarea" name="site_description"></textarea>
                        <img src="/images/info.png" class="tooltip" title="A detailed description of your schematic." />
                    </td>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="2"><input type="submit" name="submit" value="Upload Schematic" class="button" /></td>
                </tr>
            </tfoot>
        </table>
    </form>
    Can you point out what's wrong? I'm uploading a file (.schematic) and it's not being uploaded.

  • #2
    I'm still a newbie to PHP but I can see one problem. In the <form> tag you need to include enctype="multipart/form-data" otherwise it wont accept files.

    Comment


    • #3
      also, if this is going onto a non local web server, some ISP's don't by default allow files to be uploaded. If pain persists, check with your ISP.

      Comment


      • #4
        Okay I got that to work, now what I want is the name of the file to be the value of the input so I'm trying to to do this:

        PHP Code:
                        <td>Your Schematic:</td>
                        <td>
                            <input name="site1" type="file" class="input" />
                                                                                

        <?php
         $target 
        "schematics/"
         
        $target $target basename$_FILES['site1']['name']) ; 
         
        $ok=1
         if(
        move_uploaded_file($_FILES['site1']['tmp_name'], $target)) 
         {
         echo 
        "The file "basename$_FILES['site1']['name']). " has been uploaded";
         } 
        ?>
        <input name="site_url" type="hidden" class="input" value="<?php echo basename$_FILES['site1']['name']); ?>" />
        But it's not working. Any thoughts?

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎