Results 1 to 9 of 9

Thread: upload script help

  1. #1
    Join Date
    Nov 2005
    Location
    under your bed
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default upload script help

    Hello,

    I'm curently trying to develop a certain program (C++) that requires the uploading of the user's log file. I don't know php, but I do know html. My buddy made me an upload file script in php, but to use it to upload, I would have to either directly give out my upload site (which I don't want), or simulate program keystrokes and mousclicks to manually upload, which is not only a huge pain, but defective and freaky for the user. I don't know much about php, but I noticed that sometimes they refer to some kind of variable name in the url, for example:
    "http://www.myexample.com/index.php?user=me"

    Would it be possible to make a script where the filepath to upload can be defined by the url? Maybe like this:
    "http://www.wibumbasoft.tk/upload.php?filetoupload=C:\example.txt"

    That way my program can use
    "Run, http://www.wibumbasoft.tk/upload.php?filetoupload=%savepath%"
    "%savepath%" being the defined path of the file to upload.

    If there is any other way of accomplishing this without interacting with the page itself, maybe using another language, that would be great. Thanks.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Those are called GET variables in php. (As opposed to POST... the two ways form data can be sent.)

    $_GET['varname'] will be that value.
    EX:
    index.php?var=value
    $_GET['var'] is "value".


    Now... the issue will be that, due to security, the user may need to actually select the file themselves. I wonder, though.
    Might also depend on the OS the person is using.

    Maybe just try this simple code on a php page, where you use page.php?file=PATH to set which file. See if it seems to work.
    Code:
    <input type="file" value="<?php echo $_GET['file'];>">
    With just that, you should be able to tell if the file was selected... it would be like if you used the browse button to choose the file, except like you had already done that, or something.

    (To actually use that in a form, you'd need more stuff, not to mention the page that actually uploads the file, but, yeah, that will see if it's worth going farther.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    No, you're on completely the wrong track. The path of the file need never be sent to the server. The file itself is sent; the server doesn't somehow reach into the client's hard drive and pluck the file from the specified place.

    You send POST data directly in the request. The request format is:
    Code:
    POST /path/to/file.php HTTP/1.1
    Host: mysite.com
    Content-Type: multipart/form-data; boundary=---------------------------15415454588765403441079621624
    Content-Length: 254
    
    -----------------------------15415454588765403441079621624
    Content-Disposition: form-data; name="ufile"; filename="filename.fil"
    Content-Type: application/octet-stream
    
    Content goes here
    -----------------------------15415454588765403441079621624--
    That boundary can be anything. It's usually randomly generated. The lines are, of course, seperated by 13,10.

    Which socket library are you using?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Nov 2005
    Location
    under your bed
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry man, but I don't know any php. And I really don't know what a socket library is.

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Twey, wouldn't what I'm saying work, in the sense that it would open a page that would have an "upload" button that would then work based on the chosen file?

    Clearly it's not perfect... and what you're suggesting shortcuts a bunch, so it's probably better. But... would it not work?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    djr33: No, the problem is that s/he wanted it done automatically, without user intervention.

    wibumba: I didn't use any PHP I was just outlining how to perform POST requests, which can then be used with any socket-enabled language (probably C++ in your case). A socket library is a library that wraps kernel socket functions, such as UNIX sockets, winsock, or a more abstracted library like Qt sockets.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Right, but you could use that, add a javascript function to automatically send the form when it loads, and there you go. You'd need to have the page open anyway for the time it takes to transfer the file to the server.

    If the second solution will work, that's better. The first is a fairly simple way to cheat, though. heh.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You'd need to have the page open anyway for the time it takes to transfer the file to the server.
    We're trying not to involve pages here
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Ah. That's better... if it works
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •