473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Best way to get the contents of a local file in a server variable

My script acts on a file (approx. 100k) offered by the user. Actually, it
acts on a variable that should have the contents of that file in it. I
could try to let users upload that file and then read that file into a
variable, but before I figure out how to do that: is this unnecessary
overhead? Is it possible to do it without creating a file on the server
filesystem and do it completely within the PHP framework? What method
would you recommend?
Oct 29 '07 #1
3 1366
Fons <fo**@fons.invalidwrote in
news:47***********************@news.skynet.be:
My script acts on a file (approx. 100k) offered by the user. Actually,
it acts on a variable that should have the contents of that file in
it. I could try to let users upload that file and then read that file
into a variable, but before I figure out how to do that: is this
unnecessary overhead? Is it possible to do it without creating a file
on the server filesystem and do it completely within the PHP
framework? What method would you recommend?
what are you trying to do?
Oct 29 '07 #2
On Mon, 29 Oct 2007 20:07:29 +0100, Fons <fo**@fons.invalidwrote:
My script acts on a file (approx. 100k) offered by the user. Actually,it
acts on a variable that should have the contents of that file in it. I
could try to let users upload that file and then read that file into a
variable, but before I figure out how to do that: is this unnecessary
overhead? Is it possible to do it without creating a file on the server
filesystem and do it completely within the PHP framework? What method
would you recommend?
Just let it do a normal fileupload to a/the tmp directory and read it into
a variable. Anything else will be a waste of time. The code is pretty
simple:

if(isset($_FILES['your_html_fileinput_name'])){
if($_FILES['your_html_fileinput_name']['error']!=UPLOAD_ERR_OK){
echo 'upload error #'.$_FILES['your_html_fileinput_name']['error'];
} else {
$filecontents =
file_get_contents($_FILES['your_html_fileinput_name']['tmp_name']);
}
} else {
echo 'no upload took place';
}
--
Rik Wasmus
Oct 29 '07 #3
On 29 Oct, 19:07, Fons <f...@fons.invalidwrote:
My script acts on a file (approx. 100k) offered by the user. Actually, it
acts on a variable that should have the contents of that file in it. I
could try to let users upload that file and then read that file into a
variable, but before I figure out how to do that: is this unnecessary
overhead? Is it possible to do it without creating a file on the server
filesystem and do it completely within the PHP framework? What method
would you recommend?
Explaining the problem better would be a good start.

You can't get a file from the client to the server without uploading
up (unless you use signed javascripts - try a different newsgroup for
more info). 100k is getting a bit large to keep in a PHP variable,
though it will work.

C.

Oct 30 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Dave Smithz | last post by:
Hi There, I have taken over someone else's PHP code and am quite new to PHP. I made some changes and have implemented them to a live environment fine so far. However, I now want to setup a...
1
by: Bart Plessers \(artabel\) | last post by:
Hello, Currently developping a site, where I use some session variables. The site is located at my home computer. Because I have a dynamic IP adress, I use no-ip (www.no-ip.org) to have my...
2
by: Steve | last post by:
I developed a desktop app that reads an XML file into a dataset. (The desktop app has the XML schema built in, so it already knows what format the XML file should be in.) My problem is that I...
7
by: TLM | last post by:
I am trying to build a web application that will contain links to files on a users local computer. I am assuming that the files will be in a known location and can display in a browser window. ...
0
by: AAJ | last post by:
Hi all I do all my development on my local machine, and then use the 'copy web site function' to transfer data to the live web server. When I connect to the web server I would like to see the...
3
by: =?Utf-8?B?R3JlZyBN?= | last post by:
Hello, I'm running an asp.net, intranet web application using .net framework 1.1 on IIS5.1 / 6.0. Through the web application, I would like to press a button on the web page, have another window...
6
by: John Kotuby | last post by:
Hi all, I am using a 3rd party program in a VS2005 web project. The tool takes as input a string containing HTML and converts it to RTF. I have been creating a page by dynamically loading...
0
by: Shaikh shahnawaz | last post by:
Hi, I have implement multiple file uploading progress bar with the help of flash and .net file is upload on my local machine but not working with server it's give error while uploading image on...
2
by: Ashley | last post by:
hey, what's up............................. "Neil" <nospam@nospam.netwrote in message news:8YFwj.10509$0o7.1113@newssvr13.news.prodigy.net...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.