Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Copy Large XML Output To A Local File


I have a URL that when called generate a very heavy XML Feed like:

www.domain.com/generateXML.php?id=products

when i call this URL in the browser i can see a very long XML file generated containing different information..i want to copy this all output to a local file on my server so that i can use that file's info for different tasks on my site...PHP Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
PHP Copy To Local Machine?
I am building a small page to copy files from our server(s) to our users
local machines. It's very simple...
(below, "f" is a mapped network drive)

<?php

$source_file = 'f:somefile.whatever'
$destination_path = (I want to move it to the USERS
C:somedirectorysomefile);

copy($source_file, $destination_path);

?>

Template Create Each Output Copy
I'm preparing a php template which will take variables from the post form and will generate output in html format on server. To make it more customize, i wanted to give file name in post form so i must know which file has generate. How should i get started with that. Any Tutorial in this regard.

Output Large Arrays To Html
I'm looking for ways to 'echo' a single large associative array
repeatedly w/ as little overhead as possible.

I'm developing a simple subscription form, two steps, one page. In
step 1 the subscriber selects their country from a drop down menu
whose name and value pairs are based on ISO standards. In step 2 user
has the option to return to 1 and edit.

I mined the ascii data from the ISO Web page src, edited it, and
dumped it to MySQL, intending to dynamically generate my menu. But now
I'm concerned that every time a subscriber wishes to edit input, they
will experience a lag in the middle of the page while some 200+ select
options are echo'ed to the screen.

I've attempted to solve that concern using the following technique in
a global scope:

if (!isset($huge_assoc_array))
$huge_assoc_array = mine_from_db();

Does this accomplish the intended result, reducing print-to-screen
time on requests beyond the first? If subscriber clicks input button
'edit,' returning to step one, will mine_from_db() execute again?

Not sure of the answer, I've considered two alternative techniqes:
a) $_SESSION['huge_assoc_array'] = mine_from_db(); and
b) using Curl or similar to mine, on each request, from iso.org.

If you've dealt with this I would love to hear your success and
failure stories.

Php Function To Read Local Python Script Output, Not Code
On my server python has to run in the wwwroot/cgi-bin folder, but php can run anywhere. My site is going to be written in python but I don’t want my user to see the url as mysite/cgi-bin/... .

So for example my homepage, index.php should contain a simple php script that will get my python page from the cgi-bin directory and display it. However when I try to use SSI or fopen/file_get_contents/readlink and commands like these it just displays the python code. Where as when I visit the python page in my browser it runs it and displays the output for me.

My question is what php function can I use to execute my python page and return the output, not the code itself. (I think my hosting provider has disallowed certain powerful commands like system() etc. Does this make it impossible?). As the very least can’t my php script pretend to be a www user and ‘visit’ the python page to read the output?

FIle Uploads: Empty _POST And _FILES Arrays When File Too Large
Uploading of files.. AFAIU from the manual, if a file is larger than the
size defined in the form or larger than upload_max_filesize in php.ini,
that _FILES['file']['error'] should hold an INT error code.

The file upload system is working fine if the file is smaller than the
defined size, but if it's larger, then both the _POST and _FILES arrays
are completely empty:

array(0) {
}

I can obviously check to see if $_FILES is set and contains elements,
but I was hoping for more specific error handling (reason as to why the
upload failed).

Has anyone else encountered this? Any info welcomed =)

PHP File Upload Unexpected Error - File Too Large?
I have a short basic script to upload files. It works fine with small files,
but with longer files it gets stuck.

Here's the fragment, the input file is loaded in "$file" from an HTML form
as usual.

....
$img_str = fread(fopen($file, "r"), filesize($file));
$data = addslashes($img_str);
// --------------------- up to here the execution is correct and fast (<1
second)

$sql="INSERT INTO $table (".
" file_name,".
" file_type,".
" file_size,".
" bin_data)".
" VALUES (".
" '$file_name',".
" '$file_type',".
" '$file_size',".
" '$data')";
// --------------------- it gets stuck
here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
mysql_query($sql) or die ("SQL error ..$sql");

I have already set the php.ini variables as follows:
memory_limit = 16M
upload_max_filesize = 6M

I also checked the execution time to max_execution_time = 300 (even though I
don't believe it should be necessary).
The server is a P4 1.8 GHz, 256MB RAM

Copy A File From A Different Url
Hi

I am trying to copy a file froma different url but failing!

I am trying -

copy ("http://www.site.com/image.jpg" , "temp.jpg");

but getting an '

Unable to open 'http://www.olgaedwards.com/photos/2041.jpg' for reading: No such file or directory' error.

Strange because it exists and -

$file = fopen("http://www.site.com/image.jpg" , "rb");

works ok!

I even tried -

$file = fopen("http://www.site.com/image.jpg" , "rb");
copy ($file , "temp.jp");

But the same error.

Copy A File With PHP
Im trying to copy a file from the root of my website to other folder..

$source='/home/content/maunalava/html/dev-netteampr/portales/index.php';
$destination=('/home/content/maunalava/html/dev-netteampr/portales/' . $usuario);

copy($source, $destination);

But I keep getting...failed to open stream: Is a directory in....

Posting Local File Info To A Php File!
I have a script that I run locally and im trying to get the info to post to a php file so that I can view it in a browser. What I need to know is how to set up the receiving php to post it to the .html . Now I thought it went along the line of creating the php file and putting it on the root of the server then running the local script against a that php info file and it would dump the info to a browser but it wont work like that (I'm guessing cause it's a local script and not on the web)

I know this line is sending it to the .php in that directory but I don't know how to set up the receiving php I guess is my problem.

gosub phpsend www.xxxxxxxxxxxxx.com /xxxxx/xxxxxxxxx.php %sendstring

I guess what I need to know is whats the best way to post the received data to a browser after the script runs. Or to set up the receiving php file as for outputting it I can create the page I just need to know how to receive it .

Large SQL File
How can I load a 1.2gb SQL file into phpmyadmin?

Copy() Deleted File?
I use this to upload boxart for games for my site.

Copy A File To The Server
is it possible to copy a certain given file from a set location to the server everytime the page is accessed?

I have to build a site wehere daily new information has to uploaded to an intranet server, like new exchange rates. therefore i want to build a script that automaticaly uploads a csv-file to the server whenever it is accessed. the file that has to uploaded resides(and is updated) an a certain machine on the lan. is this possible? and how would you do it? PHP Code:

Copy($file, $address)
trying to use copy($file, $address) and it throws this back at me...

Warning: open_basedir restriction in effect. File is in wrong >directory >in /home/sites/site170/web/admin/experiments/uploader.php on line 57

is this a permissions problem?

File Permissions After Copy()
This function basically creates a new dir in a determined location and copies the files from an established dir to the new dir. It copies the files and creates the folder ok, bit it sets the file permissons to 755 for the new folder and file contents. I then get a 550 error if I try to delete or chmod them. Any suggestions? I get permission errors in the script if I use the chgrp and chmod functions also. PHP Code:

Copy Of Zlib File
I goofed up my linux beater box at home and I need to reinstall. It seems that zlib is located at http://www.zlib.net, but that site isn't working. I was wondering if someone has a recent release they could e-mail.

File Copy Error
Here's a piece of code I'm running on my server though I keep getting the following error. I'm not too sure what might be the issue, however, I have the permissions set properly - though I doubt if I'm using the right folder paths. Cheers and regards,

The Code:

Copy File From One Server To Another
How can I copy a file(s) from my server to another server? I trying to keep files on a develpment server current with a production servers files. So if i have files "a", "b", "c" on the production server, and files "b", "c" on the develpment server, i want to copy "a" from the production server. Is this possible? Also is it possible to upload a file to several destinations?

Using PHP To Copy A File Over The Network
im using IIS and php 4, im trying to write a bit of code that will cope a file from 1 network location to another

i have tried 2 methods using the copy command, the first is mapping the network location onto the webserver

then going copy('x:example',... etc

the other method is using UNC paths, both work fine if i call the php script from the command line like c:phpphp.exe c:myscript.php
this works fine but from a browser i just get file cannot be found,

i have tried setting setting various permissions on the destination server, tried changing the IUSR_ account to a domain account etc,

Large File Uploads
I've got a client who wants to allow his clients to upload 100MB files thru HTTP. He also wants a progress meter. I'm using the megaupload progress meter, minus the 5MB filesize limit. I've also set my apache transfer timeout to a ludicrously high number, and in php.ini I've set upload_max_filesize, max_execution_time, max_execution_time, etc to values that should allow for large file uploads.

I can upload files of several MB, but w/ anything larger, either the transfer hangs or $HTTP_POST_FILES is empty for the processing script. megaupload uses some perl/cgi code to handle the post data and show the progress meter, but I looked thru it carefully and nothing in there seems to be likely to cause a problem. Can anyone give me advice on what else I should look into? This is driving me NUTS...

Trimming A Large Log File?
I am looking for a simple way to keep my log files from growing too
large. Basically I would want something that truncates the off first 25
kb of a 100kb log file. I could do something with reading in the file
twice, first to determine number of lines. Then a second time to write
a copy of the reduced log file. Any simpler workarounds?

Large File Not Being Sent To Client
My company produces reports for our customers in PDF format. I have a
php script that verifies login status and access rights, and sends
the pdf to the client using readfile().

This has worked fine until recently. One of our customers' reports
is 10.6MB, and the customer never receives it and I can't get it
either. I checked the Apache access_log, and it shows varying
amounts of bytes being sent, but always close to 10MB.

I tried changing the php script to do fopen(), fread(), echo,
ob_flush() and flush(). After each flush, I write a message to a log
file. The messages in the log file stop at 10MB, as if the php script
is hung.

Using a network monitor, I see the connection being established, the
HTTP GET being sent, but no content coming back.

PHP version is 5.1.2
Apache is 2.2.3
OS is SuSE Linux Enterprise Server 10.0 - 64bit

Current test version looks like this:

ini_set("output_buffering", "0");
ini_set("implicit_flush", "1");
ini_set("memory_limit", "100M");
ini_set("max_execution_time", "600");
$lth = 0;
$in = fopen($path, "r");
while (!feof($in)) {
$data = fread($in, 8192);
$lth += strlen($data);
$errLog->WriteLog("Read $lth bytes" , "debug.txt");
echo $data;
$errLog->WriteLog("After echo" , "debug.txt");
ob_flush();
$errLog->WriteLog("After ob_flush" , "debug.txt");
flush();
$errLog->WriteLog("After flush" , "debug.txt");
}
$errLog->WriteLog("Got EOF", "debug.txt");
fclose($in);
$errLog->WriteLog("End of Script - read $lth bytes", "debug.txt");

The last five lines of the debug.txt log file say:

Read 10223616 bytes
After echo
After ob_flush
After flush
Read 10231808 bytes
After echo

Copy File From Email Attachment
I want to retrieve mail and save the attachment from it on my server. That works pretty well until the image copy.
With the code below I can see the image in my webbrowser. But how can I copy it to my /files directory? PHP Code:

PHP Handle Large File = DNS Error?
I have installed PHP4 with Apache 2 in my Redhat Server. However, I found that it will show DNS error when PHP handle file which over 500k. (e.g. upload file over 500k shows DNS error page, forward mail in webmail with over 500k attachment will also show DNS error page...)

Anything wrong with PHP4 or Apache 2..?

(in php.ini, upload_max_filesize = 2Mb)

Large File Is Downloaded With 0 Size
I am creating an excel file and then making it download by the browser. The
problem is that if the size of the file is less , than everything is ok ,but if
the size goes above say 200 KB than the file is downloaded with 0 bytes as size.
The code i am using is
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header ("Content-type: application/x-msexcel");
header ("Content-Disposition: attachment; filename="" . basename($fl_name) .
""" );
header ("Content-Description: PHP/INTERBASE Generated Data" );
readfile($fl_name);
--------

Large File Download Problem In IE
I have a menu link that sends you to a download page, which gets the file name and location from a DB to grab a file outside the web directory (using sessions and SSL). This works great with small downloads.

However when downloading a large file (a few megs) you can no longer click other menu links or go to other pages - everything times out! (however the download will complete successfully) This is only in IE, and it works fine in Opera and Netscape. Does anyone know what setting or header IE needs to be happy? PHP Code:

Handling Large File Uploads
I'm having some trouble with handling large PHP uploads from a form. I have <input type="hidden" name="MAX_FILE_SIZE" value="20971520"> in the form, so it should have no problem handling file uploads up to 20 Megs.

However, whenever I upload a file any larger than about 8 or 9 Megs, it outputs a "Cannot Find Server" error to the browser (tried it with IE5.5 and NN4). Some directives in the PHP.INI file have also been set to try and curb this error:

upload_max_filesize = 22020096 ; 21 Meg limit on file
max_execution_time = 600 ;600 seconds for max. script
memory_limit = 29360128 ;28mb to accomodate larger file
post_max_size = 23068672 ;22 Meg Max post *added*

php version is: PHP 4.1.2-3

How To Read Only Some Lines From A Large File
I want to read only some lines from a large text file, say lines 27 through 45. So far, I used PHP Code:

Include Large File - Right Choice ?
I've a file in wich I've almost all the text of my website. I do this
because the site is multilingual and this is easier to translate.

The file is becoming ever larger as we add new pages on our site. Actually
the file is about 100ko

I know the page is only used server side (I use a require_once) but wouldn't
be better to create a "common" file wich will be about 20 ko large (with
menus and some other text that will be always shown) and some little file
wich have the same name of the page (like index.php linked to eng-index.php)
in wich there is only the desired text for the desired page ?

What's better for the server ? would this really improve page process time ?
Or there is a way to "cache" this file in memory for faster delivery ?
(Apache server on Linux)

Has anyone a good feedback of experienced development ?

Treat Large String Like File
I've got some PHP code that reads in a file and parses some data as
it goes along.
However, now I'm thinking it might be easier for me to store chunks of
the file in the database rather than all the bits of data, so that it
can be interpreted in different ways if need be. But the problem is,
now I can't just use fread to read in two bytes of data, because I've
already got the whole chunk stored in a variable. And I really don't
want to deal with tons of substrings, it would be much easier to have a
sort of file pointer. So is there any way, or any set of functions
that I can use to deal with this?

Using A Flat File For Large Queries.
I have 13 rows of information, and instead of storing that little amount of data in the database, I figured I should save some storage and put the information in a flat file instead. Lets say my flat file looks like this:

Account type (int) | amount (int)| more info
Account type (int) | amount (int)| more info
Account type (int) | amount (int)| more info

Lets say my database table looks like this and there are about 5,000 rows.

UserID
Account_type

Would it be insane to loop through the flat file for each individual DB entry and find the matching "account type" for that individual user, then add the "amount" field to a row in the DB according to what account type they have? Or would this be a lot easier if I just stored the flat file information in a table in the database?

Large File And Ftell, Fseek
I have an extremely large text file (9GB) of data that I am trying to get into MySQL. I have a php code that opens the file, reads in the data line by line and stores each line in the appropriate database. The problem is that the server that I am using won't allow the file to be opened for more than 30 seconds.

To get around this, I started doing a ftell after each line write and then when the program is rerun, that position is read from another text file and an fseek goes to that point to start again. The problem that I have is that occasionally, the ftell seems to return a 0 and the program starts from the begining.

Writing To A Local File
We have a PHP/MySQL database application. A user would like to be able
to run a routine to read selected data from the database and export a
flat file to their local C: drive. After reviewing the documentation
and posts, it is not clear how to do this, or even if it is allowed by
the browser. If someone could point us in the right direction, we
would greatly appreciate it.

The application is hosted on a Linux server.
The users are required to use Internet Explorer running on Windows 2000
or XP (we also use VBScript).

Can I Launch A Local .bat File With PHP?
I need to write small web app that can launch a few .bat files from a local machine.
Is this possible with PHP, or would javascript be a better option? All i need to do is select the file (some HTML) then have a button to execute.

Check If A File Is Local
Is There A Function Or Method Which Can Check Wether A File Is Local.

Unable To Upload File Using Copy Statement
I need to upload files to my server but it won't let me, it comes up with the error relating to the copy if statement, which sits in the upload_file function about half way down the code. The userfile_name and the filename1 are variables passed from a form to the upload_file function.

Below is the code for the copy statement, can anyone see any major problems?

//Displays an error message if can't copy the file, from the temp dir to the directory on the server
if(!@copy($userfile_name, "$dir/$filename1")) {
error_message("Can't copy $userfile_name to $dir/$filename1.");
}

Copy Uploaded File To Remote Location.
is there anyway to copy a file when uploaded through a html form. to a remote location using the copy() function?

say for instance i have my site pages on.... www.pages.com
but i want to store the uploaded files on ... www.files.com

both are on different servers can i use the same php upload script to copy the files to the remote location and store information about them in the database on localhost @ www.pages.com is this possible? or can the copy function only copy to a local location?

Copy File With A Specific Begining Like 'thumb_'
could some help in writing a php code for copying specific files that start with 'thumb_' only and no other file. like we copy files with specific extension i want to copy files with specific starting.

Trimming Extra Spaces From Large DB File
Hi, I need some advice on what to do. I have this MySQL insert file,
with about 30,000 records. One of the datafields has names in it. When
this list was put together, apparently there was extra space formatting
inserted at the end of each name. I want to remove these, so for
example:

INSERT INTO `table_one` VALUES ('John Doe ', 1);
INSERT INTO `table_one` VALUES ('Jane Doe ', 2);
INSERT INTO `table_one` VALUES ('Baby S. Doe ', 3);

I want:

INSERT INTO `table_one` VALUES ('John Doe', 1);
INSERT INTO `table_one` VALUES ('Jane Doe', 2);
INSERT INTO `table_one` VALUES ('Baby S. Doe', 3);

I was thinking some kind of script could be put together to trim the
extra spaces out. I have this entire insert list as a text file and can
re-insert it, or leave it in the DB and run queries against it. What
complicates this for me is some of the name fields have middle names,
some do not. Maybe something to remove all spaces greater than one on a
first pass, and then on a second pass trim the extra space at the end
only. That is what I think of in theory - but have no idea how to
create such script.

Large File Uploads (100MB) With PHP/Oracle
Quick question about large file uploads with PHP/Oracle. I've been assigned to work on a project where I'm going to build a PHP front-end to an Oracle back-end. This all centres around E-Learning, and I'll need to allow people to upload Learning Objects (ie., video files, audio files, text documents, PowerPoint presentations, etc.) which will be inserted into the database as BLOBs, and then also allow people to group the Objects together into courses which could then be accessed.

What scares me is the fact that some of these objects could be up to, or more than, 100MB in size. Has anyone here done any work with handling the upload of such large files with PHP? Obviously I would need to alter the upload_max_filesize and max_execution_time values in php.ini to accomodate for this, but I'm wondering how well http uploads will actually work with objects of up to, or more than, 100MB.

The Best Method To Send A Large File To Client?
I have many text file with 1 to 2MB in size

currently, i use the method:

echo file_get_contents( $file_path );

are there any better method?

Large File Upload And Process Techniques
Well I've been trying to process a 25,000 record file and thanks to some help here have managed to do so. So then I worked on a 50,000 record file and this time it uploads, begins processing, then it hangs.

The browser stays open, keeps acting like it's thinking but never comes back. It processed a bunch of rows but then hangs. If I try it different times, it will do the same, having processed a different number of rows each time, even though the code and the data are the same. The file is just over 5 meg. The parameters I changed to help make this all work include: PHP Code:

Reading Local File Not On Server
I am trying to parse a file which is located on the users local drive and then take this data and put it into the mySQL DB. However, I get errors when I pass in a file path such as C:Documents and SettingsAdministratorDesktopfooSLInfo.txt.

Read File On Local Drive
lets assume that the sysadmin granted to read those files, what php functions needed? can u give me ur ideas how to do it?

How To Process A Local File Rather Than Just Read It
I can read a local file with

fopen("myFile.php");

However this gives me the source of the file (i.e. php code). I want
to get the results of the file after it has been evaluated (i.e. HTML).

The obvious way of doing this is

include 'myfile.php'

However, I want to process the evaluated result. For example:

echo htmlentities( include 'myfile.php' );

This doesn't work because the result of the include statement is true
or false rather than a string.

I'm sure this is very simple, but I'm just learning.

Error: Unable To Cache A Remote File Using Copy
I used the following code to copy a remote file to my server:

copy($URL,$cachefile);

This worked very well on my old server, but it does not work on the new one.

I am getting the following error:

Unable to open 'http://[...]' for reading: No such file or directory in /local/copyfile.php on line 23

I searched for more than two hours, but I have not found the solution.

On the php.net I found the following:

Note: As of PHP 4.3.0, both source and dest may be URLs if the "fopen wrappers" have been enabled.

I am using PHP 4.2., though I don't think that this is the reason, why it does not work.

Importing Large Amounts Of Data Via File Upload
I was wondering how anyone here deals with move large amounts of
mysql data to be uploaded to the server? Large as in 75MB CSV file. I
have a client who wants to admin there database with 15,000 users.
They manage all data offline and want to upload to the site for
display purposes only. My server has 5MB php file upload limit. I
really do not want to up this limit.

What I am wondering is how does cPanel or PHP MyAdmin get around this
upload limit using php scripting?

Deleting Lines From Top Of A Large Open Text File
I am splitting up one huge text file in several smaller files to prepare them for database processing. So far I tested it with files up to 100MB and everything works fine.

Now here's my question: To optimize my script I would like to incrementally remove all lines form the original file which have already been copied to the smaller file.
This would speed up reading the original file in each loop.

Unfortunatelly I couldn't find a way to remove/delete lines from an open file. Of course I could read the whole file, delete the lines and then write it back. But for files bigger than 1 GB this doesn't seem to be a good idea....

Allowed Memory Error When Loading Large File.
Using the below code:

<?php

$dictionary = fopen('US.dic','r');

while (!feof($dictionary))
{
$lines[] = fgets($dictionary, 24004096);
}

fclose($dictionary);

?>
I receive this error:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 24004097 bytes) in C:wwwdicd.php on line 8

The file is 1,185K

I am using WAMP for server. Do I need to change some settings or is there a better way to load large files.

Image Upload Failing (Large File Size)
I'm having a problem with this image upload script since I upgraded Apache. I noticed in my .htaccess files it no longer let me set maxupload size and it blanks it out saying it is now controlled by the .ini file. This script worked fine till the upgrades. The error I get is for files over 309 KB. Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved