PHP and File uploads

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • HC

    PHP and File uploads

    One of the websites I work with has a form to fill in which includes an
    input to allow me to upload a file. I'm trying to write a PHP script to
    automate the process, but I can't figure out how to make PHP upload the
    file. I've been playing about with curl, but haven't had any luck.

    The issue is that the data I want to upload isn't actually in a file;
    it's sitting in a variable in a PHP script, and all the examples I've
    found seem to assume an existing file, which for various reasons I want
    to avoid.

    If anyone could point me in the right direction, I would really
    appreciate it!

    HC
  • HC

    #2
    Re: PHP and File uploads

    HC wrote:[color=blue]
    > One of the websites I work with has a form to fill in which includes an
    > input to allow me to upload a file.[/color]

    I should have mentioned, this is done over SSL.

    Thanks,
    HC

    Comment

    • Ehsan

      #3
      Re: PHP and File uploads

      Is it that you have the data in a variable and you want to create a
      file on your server and insert the data present in the variable into
      the file? if so, then fopen(), fwrite() are the functions you should be
      looking at.

      Look in the manual for detailed information.

      Hope this helps.

      Thanks and God Bless!!

      Ehsan


      Comment

      • Jerry Stuckle

        #4
        Re: PHP and File uploads

        HC wrote:[color=blue]
        > One of the websites I work with has a form to fill in which includes an
        > input to allow me to upload a file. I'm trying to write a PHP script to
        > automate the process, but I can't figure out how to make PHP upload the
        > file. I've been playing about with curl, but haven't had any luck.
        >
        > The issue is that the data I want to upload isn't actually in a file;
        > it's sitting in a variable in a PHP script, and all the examples I've
        > found seem to assume an existing file, which for various reasons I want
        > to avoid.
        >
        > If anyone could point me in the right direction, I would really
        > appreciate it!
        >
        > HC[/color]

        HC,

        I'm not clear what you mean wit "input to allow me to upload a file".

        Are you saying you have a field where you place a filename and the file gets
        upload? Or is this a textarea you need to paste the contents of the file for
        uploading?

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • HC

          #5
          Re: PHP and File uploads

          Jerry Stuckle wrote:[color=blue]
          > I'm not clear what you mean wit "input to allow me to upload a file".[/color]

          Basically, the form has <input type='file'>. The script I'm trying to
          write should send data to that for processing.

          Ehsan, I do know how to use fopen() and fwrite(), but ideally, I don't
          want to have to write the data to a file.

          Thanks for both of your replies :)

          HC

          Comment

          • Jerry Stuckle

            #6
            Re: PHP and File uploads

            HC wrote:[color=blue]
            > Jerry Stuckle wrote:
            >[color=green]
            >> I'm not clear what you mean wit "input to allow me to upload a file".[/color]
            >
            >
            > Basically, the form has <input type='file'>. The script I'm trying to
            > write should send data to that for processing.
            >
            > Ehsan, I do know how to use fopen() and fwrite(), but ideally, I don't
            > want to have to write the data to a file.
            >
            > Thanks for both of your replies :)
            >
            > HC[/color]

            Well, you can plug a default filename in there. But you can't actually retrieve
            the file from the client computer with PHP. You need the user to fill in the
            field and submit the form.



            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • Jerry Stuckle

              #7
              Re: PHP and File uploads

              Jerry Stuckle wrote:[color=blue]
              > HC wrote:
              >[color=green]
              >> Jerry Stuckle wrote:
              >>[color=darkred]
              >>> I'm not clear what you mean wit "input to allow me to upload a file".[/color]
              >>
              >>
              >>
              >> Basically, the form has <input type='file'>. The script I'm trying to
              >> write should send data to that for processing.
              >>
              >> Ehsan, I do know how to use fopen() and fwrite(), but ideally, I don't
              >> want to have to write the data to a file.
              >>
              >> Thanks for both of your replies :)
              >>
              >> HC[/color]
              >
              >
              > Well, you can plug a default filename in there. But you can't actually
              > retrieve the file from the client computer with PHP. You need the user
              > to fill in the field and submit the form.
              >
              >
              >[/color]

              Actually, I'm wrong. You can't plug a default filename in. I was thinking of
              and text input field.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              Working...