Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Photo upload using PHP and HTML5

Photo upload using PHP and HTML5

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
htmlphpcomquestionannouncement
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    Hi, I would like to ask if anyone tried upload a photo using PHP and HTML. I don't want to use Browse and Upload buttons. I just want the user to click on Upload which will browse then upload immediately to a dynamic folder. are there any good free plugins available? or your recommend to code it? Thanks,

    Technology News @ www.JassimRahma.com

    U W 2 Replies Last reply
    0
    • J Jassim Rahma

      Hi, I would like to ask if anyone tried upload a photo using PHP and HTML. I don't want to use Browse and Upload buttons. I just want the user to click on Upload which will browse then upload immediately to a dynamic folder. are there any good free plugins available? or your recommend to code it? Thanks,

      Technology News @ www.JassimRahma.com

      U Offline
      U Offline
      User 10838593
      wrote on last edited by
      #2

      use ftp right?write(program) a can upload's website,right?use the html 5 and javascript code,right?,im a beginner and im a chinese.i have alway practise my english

      1 Reply Last reply
      0
      • J Jassim Rahma

        Hi, I would like to ask if anyone tried upload a photo using PHP and HTML. I don't want to use Browse and Upload buttons. I just want the user to click on Upload which will browse then upload immediately to a dynamic folder. are there any good free plugins available? or your recommend to code it? Thanks,

        Technology News @ www.JassimRahma.com

        W Offline
        W Offline
        Weekendrockstar
        wrote on last edited by
        #3

        Here is a link that may lead you to an answer you seek. https://code.google.com/p/html5uploader/[^] This should allow users of your site to drag and drop a file from their OS to be uploaded to your site in their browser. This will create a button to 'browse' but then they should not have to click an upload button and therefore you should not have to display an upload button. You can have it save to a 'dynamic' directory/folder by manipulating the save directory in the PHP page that is shown on that site's page. Let's assume that that want files save into a directory named after the user but all user's folders are inside a directory called user_uploads. You will have to set it to an "id" that, obviously, would be unique to each user of your site. If users have a unique username then it could be $username or if they have a unique ID number associated with their account then it could be $user_id. First change the name of the upload folder to what you want...as described above I am going with user_uploads:

        $upload_folder = 'user_uploads';

        Then you would have to do an additional change to the lines shown below to add it to the dynamic folder with the user's unique ID.

        if(file_put_contents($upload_folder/$username.'/'.$headers['UP-FILENAME'], $content)) {
        echo 'done';
        }

        For safety's sake I would either create a new directory named with a registering members unique ID upon creation of a new account or at least right before the second code shown to make sure that they actually have an existing directory to download into. Although it might be better to go with the second option here as you may have a lot of members who do not want to upload anything and therefore you could end up with a whole lot of empty directories sitting in that parent directory. Creating the directory (with appropriate permissions to store and show images) right before the upload process could ensure that only those users/members that actually want to upload something will have a folder. You can download the 3 files plus the .js file from that link above. However, the link to demo this in action appears to be broken. But it's pretty simple and straightforward so it shouldn't take too much work to change a couple variables, upload to your server and test it yourself. If

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups