473,805 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 17 '05 #1
4 1892
*** 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($fil es)

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_f ile() 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
> 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($fil es)

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_f ile() 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
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
*** 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
16655
by: Vasilis Serghi | last post by:
Hi all, I am fairly new to C programming and I have come to a stand still. I am trying to create a program that will accept a user input and give the user an output depending on the contents of a csv file. So far I have successfully managed to capture the user input, open the csv file, create a structure that matches the file data, but I cannot get the data into the structure to do a search on. This is some of what I have done so far:- ...
5
2442
by: Chathu | last post by:
Hello everyone........... I have a problem on retriving a content of a binary file I wrote into. My program user structures, dynamic allocation of memory and files. I take the infomation into a dynamicaly allocated structure and then write it to a binary file using fwrite() with appending mode. I can retrive the data I wrote while the program is running. But if I stop the program and re-execute it I can't read the things I wrote to the...
0
3946
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
3
7519
by: Zahid | last post by:
Hi, I have declared an array holding a custom declared structure. The structure looks like this: Private Structure MnuDataFrmFile Public menuGroup As String Public ItemDesc As String Public ItemPrice As Integer Private PluValue As Integer
5
4351
by: Phil Kelly | last post by:
Hi I need to write the contents of a structure to a binary file - there is one string and 2 integers, but I can't seem to figure out how to write the data correctly. If I am simply writing text to a file there is no problem - that starts when I attempt to write the structure. Can someone help me out, please?
8
23910
by: a | last post by:
I have a struct to write to a file struct _structA{ long x; int y; float z; } struct _structA A; //file open write(fd,A,sizeof(_structA)); //file close
9
8396
by: JimmyKoolPantz | last post by:
IDE: Visual Studio 2005 Language: VB.NET Fox Pro Driver Version: 9.0.0.3504 Problem: I currently have a problem altering a DBF file. I do not get any syntax errors when running the program. However, after I alter the table and open microsoft excel to look at any changes; I get the following error: "This file is not in a recognizable format" If I do open the file in excel it looks like its not formatted.
19
5391
by: Lee Crabtree | last post by:
Is there a class in the framework that allows me read text from a file in an unbuffered manner? That is, I'd like to be able to read lines in the same manner as StreamReader.ReadLine(), but I also need to be able to accurately get the position in the file of that line. Since StreamReader and FileStream both buffer data, you can't equate the BaseStream.Position with the data you're reading from the stream. Lee Crabtree
4
2128
by: MikeJ | last post by:
make a While loop ofs = TextFileServer("somefile") string srow while (ofs=false) { srow=ofs.getRow(); Console.Writeline(srow); }
6
3535
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features to an old program that I wrote in delphi and it's a good opportunity to start with c++.
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.