Need php help, quick question ;)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pipecrew
    Master of Gfy.com
    • Feb 2002
    • 14888

    #1

    Need php help, quick question ;)

    I have been building a few things lately for fun, This is a standard upload script, i am having trouble renaming the file, where in the code do i need to change so that i could have a random name or base the name off an Id?




    $target_path = "uploads/";
    $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!";
    }
  • Masterchief
    Confirmed User
    • Jun 2006
    • 530

    #2
    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

    the bold part is where you would place the name

    Comment

    • StuartD
      Sofa King Band
      • Jul 2002
      • 29903

      #3
      The filename is set here: basename( $_FILES['uploadedfile']['name'])

      $target_path = $target_path . 'thenamethatyouwant.jpg';

      You can have it be what you want, you aren't forced to use the name that the file was uploaded with.
      This is me on facebook
      This is me on twitter

      Comment

      • Pipecrew
        Master of Gfy.com
        • Feb 2002
        • 14888

        #4
        Originally posted by StuartD
        The filename is set here: basename( $_FILES['uploadedfile']['name'])

        $target_path = $target_path . 'thenamethatyouwant.jpg';

        You can have it be what you want, you aren't forced to use the name that the file was uploaded with.
        ahhh ok! so could i put a variable right there, if i was trying to name it based off an ID? like if the id is 16, its going to be 16.jpg?

        Comment

        • SomeCreep
          :glugglug
          • Mar 2003
          • 26118

          #5
          Pipecrew, off topic, but does Bang Bros know that something is wrong with the way they're tracking hits? I'm showing way less hits than normal for the past few days. Did you guys make some changes to the way you count hits? Are sales still being tracked normally?

          Webair Hosting

          I use and recommend Webair for hosting.

          Comment

          • Jman
            Already an AI veteran
            • Sep 2003
            • 22833

            #6
            Yo Pipecrew can you hit me up on ICQ when you have a second please. 124588247
            Orkestrait NSFW AI
            FantasyXXX.AI
            Email: [email protected] TG: @jman1216

            Comment

            • StuartD
              Sofa King Band
              • Jul 2002
              • 29903

              #7
              Originally posted by Pipecrew
              ahhh ok! so could i put a variable right there, if i was trying to name it based off an ID? like if the id is 16, its going to be 16.jpg?
              Yup, could be what ever you want... and a variable would be a good idea since you use basename( $_FILES['uploadedfile']['name']) in your success message as well.
              This is me on facebook
              This is me on twitter

              Comment

              • Pipecrew
                Master of Gfy.com
                • Feb 2002
                • 14888

                #8
                Originally posted by SomeCreep
                Pipecrew, off topic, but does Bang Bros know that something is wrong with the way they're tracking hits? I'm showing way less hits than normal for the past few days. Did you guys make some changes to the way you count hits? Are sales still being tracked normally?
                Ofcourse, with stuartd's help i am learning php to fix the system ;)

                J/k, not in a hundred years, yes we know there is a problem and its being fixed. We had a database issue on bangbrosnetwork over the weekend and the people that wrote our affiliate software have been working on everything allday, there will be a redump of all data tommorow am.

                Comment

                • SomeCreep
                  :glugglug
                  • Mar 2003
                  • 26118

                  #9
                  Originally posted by Pipecrew
                  Ofcourse, with stuartd's help i am learning php to fix the system ;)

                  J/k, not in a hundred years, yes we know there is a problem and its being fixed. We had a database issue on bangbrosnetwork over the weekend and the people that wrote our affiliate software have been working on everything allday, there will be a redump of all data tommorow am.
                  Cool, thanks for the update.

                  Webair Hosting

                  I use and recommend Webair for hosting.

                  Comment

                  • Pipecrew
                    Master of Gfy.com
                    • Feb 2002
                    • 14888

                    #10
                    Originally posted by StuartD
                    Yup, could be what ever you want... and a variable would be a good idea since you use basename( $_FILES['uploadedfile']['name']) in your success message as well.
                    thanks dude, sometimes problems need a fresh pair of eyes and experience ;) works like a charm now!

                    Comment

                    • StuartD
                      Sofa King Band
                      • Jul 2002
                      • 29903

                      #11
                      Originally posted by Pipecrew
                      thanks dude, sometimes problems need a fresh pair of eyes and experience ;) works like a charm now!
                      Anytime... glad I could help.
                      And Masterchief was correct as well.
                      This is me on facebook
                      This is me on twitter

                      Comment

                      • WiredGuy
                        Pounding Googlebot
                        • Aug 2002
                        • 34515

                        #12
                        I didn't know you were a coder
                        WG
                        I play with Google.

                        Comment

                        Working...