FILE structure

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

    FILE structure

    I've created a function with takes some files (input type="file") as
    parameter.

    Now, since this is an array of a structure, I'd like to fill this structure
    with my own datas, as I'd like to use the same function but not from a form,
    but from a self created PHP script.

    my function has the file parameter;
    myfunction($fil es)

    I've seen there is a $file['file1']['tmp_name'] field. But how to save the
    datas.

    In my case, the files are actually on my server (a program upload files on a
    directory of the server). I must use those files (actually images) to save
    them somewhere else on the site, after renaming and putting some records in
    the mysql database.

    How to fill such $file structure with the different .jpgs ?

    Thanks

    Bob


  • Alvaro G Vicario

    #2
    Re: FILE structure

    *** Bob Bedford wrote/escribió (Mon, 23 May 2005 11:37:34 +0200):[color=blue]
    > Now, since this is an array of a structure, I'd like to fill this structure
    > with my own datas, as I'd like to use the same function but not from a form,
    > but from a self created PHP script.[/color]

    Are you aware that filling the array won't automagically upload files?

    [color=blue]
    > my function has the file parameter;
    > myfunction($fil es)
    >
    > I've seen there is a $file['file1']['tmp_name'] field. But how to save the
    > datas.[/color]

    $file is not a standard PHP variable. If it's there, it's because your
    script creates it. You can modify it the same way you create it...

    [color=blue]
    > In my case, the files are actually on my server (a program upload files on a
    > directory of the server). I must use those files (actually images) to save
    > them somewhere else on the site, after renaming and putting some records in
    > the mysql database.[/color]

    You can use move_uploaded_f ile() giving the tmp_name value as parameter.

    [color=blue]
    > How to fill such $file structure with the different .jpgs ?[/color]

    As I told you, that's a custom variable *you* create. When you upload files
    what you get is an associative array called $_FILES. It's created
    automatically when the browser uploads files. As I told you, giving it a
    custom value won't upload the file. Check this chapter:




    --
    -- Álvaro G. Vicario - Burgos, Spain
    -- http://bits.demogracia.com - Mi sitio sobre programación web
    -- Don't e-mail me your questions, post them to the group
    --

    Comment

    • Bob Bedford

      #3
      Re: FILE structure

      > Are you aware that filling the array won't automagically upload files?
      I know, the files are actually on my server, like they were uploaded.
      [color=blue]
      >[color=green]
      >> my function has the file parameter;
      >> myfunction($fil es)
      >>
      >> I've seen there is a $file['file1']['tmp_name'] field. But how to save
      >> the
      >> datas.[/color]
      >
      > $file is not a standard PHP variable. If it's there, it's because your
      > script creates it. You can modify it the same way you create it...
      >
      >[color=green]
      >> In my case, the files are actually on my server (a program upload files
      >> on a
      >> directory of the server). I must use those files (actually images) to
      >> save
      >> them somewhere else on the site, after renaming and putting some records
      >> in
      >> the mysql database.[/color]
      >
      > You can use move_uploaded_f ile() giving the tmp_name value as parameter.[/color]
      This is done in my function, and the process is quite long for what I do,
      that's why I want it to be done by my function and create the structure.
      [color=blue]
      >
      >[color=green]
      >> How to fill such $file structure with the different .jpgs ?[/color]
      >
      > As I told you, that's a custom variable *you* create. When you upload
      > files
      > what you get is an associative array called $_FILES. It's created
      > automatically when the browser uploads files. As I told you, giving it a
      > custom value won't upload the file. Check this chapter:
      >
      > http://es2.php.net/manual/en/features.file-upload.php[/color]
      I'm looking for such associative array struct called $_FILES ! I repeat the
      files are already in a directory of my server, accessible by FTP.
      I want to use my function to move the files like they were uploaded by a
      FORM.

      I can't get this struct.

      Bob


      Comment

      • Oli Filth

        #4
        Re: FILE structure

        Bob Bedford wrote:
        <...SNIP...>[color=blue]
        > I'm looking for such associative array struct called $_FILES ! I[/color]
        repeat the[color=blue]
        > files are already in a directory of my server, accessible by FTP.
        > I want to use my function to move the files like they were uploaded[/color]
        by a[color=blue]
        > FORM.[/color]

        Why not just use copy()?

        --
        Oli

        Comment

        • Alvaro G Vicario

          #5
          Re: FILE structure

          *** Bob Bedford wrote/escribió (Mon, 23 May 2005 13:27:55 +0200):[color=blue][color=green]
          >> Are you aware that filling the array won't automagically upload files?[/color]
          > I know, the files are actually on my server, like they were uploaded.[/color]

          Then:

          rename Renames a file or directory available since: PHP 3, PHP 4 , PHP 5

          usage:

          bool rename ( string oldname, string newname [, resource context] )


          Don't get confused by the name, this function allows you to move files.



          --
          -- Álvaro G. Vicario - Burgos, Spain
          -- http://bits.demogracia.com - Mi sitio sobre programación web
          -- Don't e-mail me your questions, post them to the group
          --

          Comment

          Working...