473,569 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to specify path to save spread sheet file in php?

6 New Member
i want to store data ie available in a webpage in a spread sheet...

i am creating an empty excel file using..
$excel = new Spreadsheet_Exc el_Writer('hard ware.xls');

but... i dont know how to specify the path to store the file in a partiucular path...
i need to have a 'save as' button.. by clicking tat button it should facilitate the user to store the file in tat path..

friends can u help me??


thank u...
Mar 21 '09 #1
2 3115
pbmods
5,821 Recognized Expert Expert
Heya, pinocchio123. Welcome to Bytes!

A path is simply a string that uses '/' or '\' characters to separate folders. All you need to do is provide the User with a text input so that he can specify the path.

The tricky part is not collecting the path; it is validating the path to make sure that the User did not (accidentally or maliciously) specify an unsafe path.

For example:

Expand|Select|Wrap|Line Numbers
  1. $path = $_POST['path'];
  2.  
  3. $excel = new Spreadsheet_Excel_Writer($path . '/hardware.xls');
  4.  
Most of the time, the results of this code are exactly what one would expect, but you should do some extra validation just to be sure:

Expand|Select|Wrap|Line Numbers
  1. $basePath = '/path/to/safe/directory';
  2. $subPath  = $_POST['path'];
  3.  
  4. $target = realpath($basePath . '/' . $subPath);
  5.  
  6. /* Check to make sure the User didn't try to move out of the safe path. */
  7. if( strpos($target, $basePath) === false )
  8. {
  9.   throw new Exception("'{$subPath}' is an invalid path!");
  10. }
  11.  
  12. $excel = new Spreadsheet_Excel_Writer($target . '/hardware.xls');
  13.  
Mar 21 '09 #2
pinocchio123
6 New Member
thank you very much for ur suggestion.. i got it... :)
Mar 21 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2974
by: Kit Truong | last post by:
Hello, I have an asp page that produces output from a database. This allows a simple way for the user to save the data to a text file by going to File->Save as... The default save as options always defaults to a particular filename and the save as type is always html, therefore the user has to manually type a filename and choose Text...
4
5086
by: John | last post by:
Hi, I generate a report in a comma delimited file and give it a name like MyReport.csv . I then set a Hyperlink control to point tp the file HyperLink1.text = "Download" Hyperlink1.NavigateUrl = "MyReport.csv" When the user clicks the HyperLink I would always like to
0
1183
by: WStoreyII | last post by:
Hello, I was wondering if there was a way to open a spread sheet up in a windows mdi form. I have tried the spreadsheet control but that does not work because i wish to open up an exisiting spread sheet that i have. How Can this be done? WStoreyII
2
2225
by: RICHARD BROMBERG | last post by:
I wrote a small Access application that accepts a City Name and a Street Name and runs a Query based on them . I want to create an Excel Spread sheet that contains all the matches found by the Query. . Does anyone know how to do this . On a quick and dirty basis I was able to "cut and paste" the query results into an Excel Spread...
5
3181
by: stuart79 | last post by:
I am looking for a code that enables me to open another excel spread sheet while i am in my XL form i have this code - Workbooks.Open Filename:= "OtherFilename.xls" - which opens up the XL spread sheet that i need however my form sits ontop of the xl spread sheet and i am unable to do anything to the spread sheet in the back ground. I need a...
1
3398
by: Alia Khan | last post by:
Hi I am creating a dts in which I want to write my query results in a spread sheet I am using this syntax select Super_REgion, sum(num_of_offers) Contracts, sum(num_of_acnts) Accounts from #ak1 group by Super_Region into OUT File '\\nas-msw-04\c07874\My Documents\MonthlyMetricsData/MonthlyEcims Data Prep'
1
3941
by: pvenu | last post by:
Hi, I know basic perl (regular expressions, pattern matching, string manipulation, reading writing into text files). Yet, my requirement is to read an input text file -> process this input file through a Perl script and the output generated from this script is to be written into an Excel sheet file (into each cells of the sheet). Can you...
5
2440
by: cdavii | last post by:
Anyone have an idea why i get null values when i import data from a ms spread sheet in a sql tbl. The table elemet(Spread sheet) in question contains alpha numerics. The sql table is populated with "NULL" when the value is numeric only. Example: A-ASP21A1-- imports perfect 6500012111-- results in "NULL" in the sql...
1
1583
by: flickimp | last post by:
Hi I have an excel file with 20 sheets. Now then... I am only interested in one Sheet (2 pages) and I want to save that to a particular folder. Also, the sheet is dependent on Cell D7 equalling a code...that in turn feeds all of the vlookups...you get the picture For this, I added a loop.
0
7618
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...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
6286
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...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
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...
0
3656
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...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
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
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.