Announcement Announcement Module
Collapse
No announcement yet.
php question Page Title Module
Move Remove Collapse
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • php question

    #1
    i found a tutorial but I cant seem to make it work

    I have a upload.php
    <form enctype='multipart/form-data' action='uploadscript.php' method='post'>
    <input type='hidden' name='MAX_FILE_SIZE' value='2048000'>
    File: <input name='userfile' type='file' />[b]
    <input type='submit' value='Upload' />
    </form>

    JUST LAUNCHED - www.hirethisdesigner.com - check it out

  • #2
    and a uploadscript.php

    <?php
    if (@is_uploaded_file($_FILES['userfile']['tmp_name'])) {
    copy($_FILES['userfile']['tmp_name'], '$/upload' . $_FILES['userfile']['name']);
    echo '<p>File uploaded successfully.</p>';
    }
    ?>

    JUST LAUNCHED - www.hirethisdesigner.com - check it out

    Comment


    • #3
      then I have an empty folder on the server named upload

      see conceptprint.com/upload.php

      I can submit a file and the 'File uploaded successfully' works but the file is no where to be found....and yes php works on my server too

      please help a designer trying to be a developer out

      JUST LAUNCHED - www.hirethisdesigner.com - check it out

      Comment


      • #4
        I suggest you use a different script. Your current one is not very secure. It allows any file type to be uploaded.

        Like this:

        said...
        <?php
        if (($_FILES['file']['type'] == 'image/gif') &&
        ($_FILES['file']['size'] < 5000))
        {
        echo 'Return Code: ' . $_FILES['file']['error'] . '[b]';
        echo 'Uploading ' . $_FILES['file']['name'] . ' (' .
        $_FILES['file']['type'] . ', ' .
        ceil($_FILES['file']['size'] / 1024) . ' Kb).[b]';

        if file_exists('uploads/' . $_FILES['file']['name'])
        {
        echo $_FILES['file']['name'] . ' already exists. ';
        echo 'Please delete the destination file and try again.';
        }
        else
        {
        move_uploaded_file($_FILES['file']['tmp_name'],
        'uploads/' . $_FILES['file']['name']);
        echo 'File has been stored in your uploads directory.';
        }
        } else
        {
        echo 'Sorry, we only accept .gif images under 5Kb for upload.';
        }
        ?>
        That allows only gifs of a max of 5KB. What exactly will this be used for?



        If it weren't for the last minute, nothing would ever get done.

        Never put off till tomorrow what you can avoid all together.

        Comment


        • #5
          And I believe that your current script isn't working because you need to take the $ out of '$/upload'.



          If it weren't for the last minute, nothing would ever get done.

          Never put off till tomorrow what you can avoid all together.

          Comment


          • #6
            I need to accept any file up to 50mb its for my company so clients can upload there crap to us...

            its still not working..I will cry now

            JUST LAUNCHED - www.hirethisdesigner.com - check it out

            Post Edited (BIG PERM) : 7/12/2004 5:01:31 PM GMT

            Comment


            • #7
              I copied your script and it not sits there and doesnt work eventually it goes to uploadscript.php and nothing happens

              JUST LAUNCHED - www.hirethisdesigner.com - check it out

              Comment


              • #8
                Some of the variables were not the same between my script and yours.

                Use this HTML:

                <form enctype='multipart/form-data' action='uploadscript.php' method='post'>
                File: <input name='file' type='file' />[b]
                <input type='submit' value='Upload' />
                </form>

                And in my script, the directory it uploads to is called uploads, not upload.



                If it weren't for the last minute, nothing would ever get done.

                Never put off till tomorrow what you can avoid all together.

                Comment


                • #9
                  the directory is just an empty folder named uploads right???? maybe I have that wrong

                  JUST LAUNCHED - www.hirethisdesigner.com - check it out

                  Comment


                  • #10
                    Yes, it is an empty folder on the server.



                    If it weren't for the last minute, nothing would ever get done.

                    Never put off till tomorrow what you can avoid all together.

                    Comment


                    • #11
                      i have no clue what to do now..

                      whats the deal....? I hate not understanding whats wrong

                      JUST LAUNCHED - www.hirethisdesigner.com - check it out

                      Comment


                      • #12
                        Did you change out the HTML? Where is the uploads folder located in relation to the script?



                        If it weren't for the last minute, nothing would ever get done.

                        Never put off till tomorrow what you can avoid all together.

                        Comment


                        • #13
                          the script is in the same director as the upload.php

                          JUST LAUNCHED - www.hirethisdesigner.com - check it out

                          Comment


                          • #14
                            Ok, I got it working on my server.

                            I used this script (there is a small fix from the one above):

                            said...
                            <?php
                            if (($_FILES['file']['type'] == 'image/gif') &&
                            ($_FILES['file']['size'] < 5000))
                            {
                            echo 'Return Code: ' . $_FILES['file']['error'] . '[b]';
                            echo 'Uploading ' . $_FILES['file']['name'] . ' (' .
                            $_FILES['file']['type'] . ', ' .
                            ceil($_FILES['file']['size'] / 1024) . ' Kb).[b]';

                            if (file_exists('/uploads/' . $_FILES['file']['name']))
                            {
                            echo $_FILES['file']['name'] . ' already exists. ';
                            echo 'Please delete the destination file and try again.';
                            }
                            else
                            {
                            move_uploaded_file($_FILES['file']['tmp_name'],
                            '//uploads/' . $_FILES['file']['name']);
                            echo 'File has been stored in your uploads directory.';
                            }
                            } else
                            {
                            echo 'Sorry, we only accept .gif images under 5Kb for upload.';
                            }
                            ?>
                            And this is the HTML:

                            <form enctype='multipart/form-data' action='uploadscript.php' method='post'>
                            File: <input name='file' type='file' />[b]
                            <input type='submit' value='Upload' />
                            </form>

                            Try uploading a small gif and it should give an error message. In that error message, you need to copy the entire path that it gives. It should be something like public_html/folder/somedirectory/.

                            Then in that code put the path (public_html/folder/somedirectory/) in front of /uploads/ to get public_html/folder/somedirectory/uploads/.

                            Then it should work.



                            If it weren't for the last minute, nothing would ever get done.

                            Never put off till tomorrow what you can avoid all together.

                            Comment


                            • #15
                              Return Code: 0
                              Uploading ala.gif (image/gif, 3 Kb).
                              File has been stored in your uploads directory.

                              it put it in my images folder not the uploads folder...how can I change that....dudes thanks thus far... when your 21 I will buy you a beer...

                              JUST LAUNCHED - www.hirethisdesigner.com - check it out

                              Comment

                              Google search Google search Module
                              Collapse
                              Latest Topics Latest Topics Module
                              Collapse
                              • PanToshi's Avatar
                                Commented to New!
                                Welcome to GDF
                              • PanToshi's Avatar
                                Welcome
                              • Buda's Avatar
                                Hi Ves and welcome to GDF. Designing for print can be quite a steep learning curve. If you have any technical questions, feel free to ask!
                              • Buda's Avatar
                                Commented to New!
                                Welome iandi.
                              • iandi's Avatar
                                Commented to New!
                                Thanks! ill have a read through for sure.
                              • Red Kittie Kat's Avatar
                                Commented to New!
                                Welcome Aboard



                                If you are having trouble using the board, please bear with us. We are going through a major upgrade. Hopefully it will all be resolved in a few days. ...
                              • iandi's Avatar
                                Hey guys,

                                My name is Asher, I run a creative website http://www.industryandinterest.com with regular interviews and posts... aimed to inspire creatives.

                                Looking forward to being...
                              • KitchWitch's Avatar
                                Commented to The new GDF...
                                Um, that happened a while ago, lol.
                              All Creative World Network All Creative World Network Module
                              Collapse
                              WebMediaBrands
                              Mediabistro | SemanticWeb | Inside Network
                              Jobs | Education | Research | Events | News
                              Advertise | Terms of Use | Privacy Policy
                              Copyright WebMediaBrands Inc. All rights reserved.
                              Working...
                              X