By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,408 Members | 1,576 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,408 IT Pros & Developers. It's quick & easy.

FILE structure

P: n/a
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($files)

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
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
*** Bob Bedford wrote/escribió (Mon, 23 May 2005 11:37:34 +0200):
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.
Are you aware that filling the array won't automagically upload files?

my function has the file parameter;
myfunction($files)

I've seen there is a $file['file1']['tmp_name'] field. But how to save the
datas.
$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...

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.
You can use move_uploaded_file() giving the tmp_name value as parameter.

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


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
--
-- Á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
--
Jul 17 '05 #2

P: n/a
> 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.
my function has the file parameter;
myfunction($files)

I've seen there is a $file['file1']['tmp_name'] field. But how to save
the
datas.
$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...

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.


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

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.

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


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

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
Jul 17 '05 #3

P: n/a
Bob Bedford wrote:
<...SNIP...>
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.


Why not just use copy()?

--
Oli

Jul 17 '05 #4

P: n/a
*** Bob Bedford wrote/escribió (Mon, 23 May 2005 13:27:55 +0200):
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.


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
--
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.