#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    4
    Rep Power
    0

    Is PHP Optimal for This?


    Hey everybody thanks for taking the time,

    I'm super new to coding and a friend mentioned that PHP may be helpful for this - and java as well.

    I'd like to know which programming language would be best suited to make a program that can do the following things

    1. Open a browser and go to a specific URL
    2. Click on a button on the page to 'upload' a file, and select the proper file from my documents

    That's essentially the jist of the functions, if you know which language may be suitable, and what you perceive the level of difficulty to be, please fill me in!

    I'd really appreciate it,

    Taevo
  2. #2
  3. Old Fart
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Chicago
    Posts
    97
    Rep Power
    4
    It looks like you wish to emulate a web browser. I have no idea if there is a package to do this. I don't think that PHP would do the job.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by richpri
    It looks like you wish to emulate a web browser. I have no idea if there is a package to do this. I don't think that PHP would do the job.
    perhaps not emulate a web browser, but just be able to open one and then identify what on the screen to click and in what order. sort of like a macro mouse sequence but more complex. thank you very much
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    85
    Rep Power
    2
    PHP is a type of file that is ran on a server. For example XAMPP, WAMP, or from a hosting a provider. You will not be able to open a web browser with PHP. PHP is a backend type of script, that is again, hosted on a server.

    Java would be more suitable in this case. You could indeed create a browser with Java and then navigate to a webpage.

    Hope that helped!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by tjswebdev
    PHP is a type of file that is ran on a server. For example XAMPP, WAMP, or from a hosting a provider. You will not be able to open a web browser with PHP. PHP is a backend type of script, that is again, hosted on a server.

    Java would be more suitable in this case. You could indeed create a browser with Java and then navigate to a webpage.

    Hope that helped!
    Thanks a ton and I'm over to the Java forum!
  10. #6
  11. Old Fart
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Chicago
    Posts
    97
    Rep Power
    4
    PHP runs on a web server not on a browser.

    JavaScript can run on a browser.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    85
    Rep Power
    2
    I am pretty sure he was talking about Java, like Java, not Javascript. They are two entirely different languages.
  14. #8
  15. Mad Scientist
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2007
    Location
    North Yorkshire, UK
    Posts
    3,660
    Rep Power
    4123
    Once a browser is open, javaScript (not java) can open pages, trigger click events and so on.

    It is unlikely that javascript will be able to read your file system.

    However, if you are trying to automate a task on your desktop then i can recommend the iMacros plugin for firefox. If you have a lot of files then you can use php to write the macroscript (you can generate a sample one from running it manually) or work out how to get iMacros to read from a CSV
    I said I didn't like ORM!!! <?php $this->model->update($this->request->resources[0])->set($this->request->getData())->getData('count'); ?>

    PDO vs mysql_* functions: Find a Migration Guide Here

    [ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]
  16. #9
  17. Old Fart
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Chicago
    Posts
    97
    Rep Power
    4
    Originally Posted by Northie
    It is unlikely that javascript will be able to read your file system.
    Please see http://www.html5rocks.com/en/tutorials/file/dndfiles/
  18. #10
  19. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,692
    Rep Power
    6351
    Originally Posted by richpri
    This only works on <input type="file"> inputs, it seems. Those cannot be automated by javascript, it can't read local files unless a human user (or a macro) selects that file.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  20. #11
  21. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    501
    Rep Power
    127
    Originally Posted by taevo
    Hey everybody thanks for taking the time,

    I'm super new to coding and a friend mentioned that PHP may be helpful for this - and java as well.

    I'd like to know which programming language would be best suited to make a program that can do the following things

    1. Open a browser and go to a specific URL
    2. Click on a button on the page to 'upload' a file, and select the proper file from my documents

    That's essentially the jist of the functions, if you know which language may be suitable, and what you perceive the level of difficulty to be, please fill me in!

    I'd really appreciate it,

    Taevo
    I'm a little confused by the other responses.. maybe they're being a bit too literal.

    It sounds like what you're specifically trying to do is simply automate the upload of a local file through a web form of a website.

    Opening the website in a browser, clicking an upload button, and selecting the file is the very human way of doing it, but there might be more direct automated ways available to you.

    For instance, you could use a programming language to build an HTTP POST request to the same destination the form would submit to, including the desired file for upload. The mechanics to do that specifically vary by language, but the concept is common.

    So then the question becomes which language would be best for it, and really a lot of them could. Personal experience would have me say that PHP isn't a perfect fit for Windows, but personal experience has also shown how much of pain in the *** Java can be to get configured correctly for development and use. C# would probably be the easiest to use but I think you'd have to pay for it.

    So all in all... I'd still push for the use of PHP in your case.
    LinkedIn: Dave Mittner
  22. #12
  23. Mad Scientist
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2007
    Location
    North Yorkshire, UK
    Posts
    3,660
    Rep Power
    4123
    Originally Posted by dmittner
    ... use a programming language to build an HTTP POST request to the same destination the form would submit to, including the desired file for upload. The mechanics to do that specifically vary by language, but the concept is common.
    Yep, this too - I forgot to mention this after my introduction to macros. Thanks to Dave for adding it in
    I said I didn't like ORM!!! <?php $this->model->update($this->request->resources[0])->set($this->request->getData())->getData('count'); ?>

    PDO vs mysql_* functions: Find a Migration Guide Here

    [ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]
  24. #13
  25. Web Developer/Musician
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Nov 2004
    Location
    Tennessee Mountains
    Posts
    2,407
    Rep Power
    1031
    PHP CURL can do uploads if all you want to do is emulate the act of posting a form. You could also do this with node.js if you wanted to load an actual interface and script it (say for unit tesiing or something), I don't know that the usual security restrictions with upload controls and javascript would apply with some node.js tools or not.

IMN logo majestic logo threadwatch logo seochat tools logo