473,410 Members | 1,953 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,410 software developers and data experts.

Write .txt extension for $filename

133 100+
Hi guys,

i am trying to add .txt extension to the filename.

Expand|Select|Wrap|Line Numbers
  1. $filename    = (isset($_POST['filename']))    ? $_POST['filename']    : '' ;
Thanks in advanced.
Apr 17 '10 #1

✓ answered by nouras

you can use dot to add any string to the variable
like this

Expand|Select|Wrap|Line Numbers
  1.  
  2. $filename=$_POST['filename'];
  3. $filename.="txt";
  4.  
  5.  
OR
Expand|Select|Wrap|Line Numbers
  1. $filename=$_POST['filename']."txt";
  2.  

8 2642
Dormilich
8,658 Expert Mod 8TB
what’s the problem?
Apr 17 '10 #2
nouras
15
you can use dot to add any string to the variable
like this

Expand|Select|Wrap|Line Numbers
  1.  
  2. $filename=$_POST['filename'];
  3. $filename.="txt";
  4.  
  5.  
OR
Expand|Select|Wrap|Line Numbers
  1. $filename=$_POST['filename']."txt";
  2.  
Apr 17 '10 #3
gobblegob
133 100+
@nouras
Thanks Nouras, you are a champion!

i got it with this :)
Expand|Select|Wrap|Line Numbers
  1.         $filename    = (isset($_POST['filename']))    ? $_POST['filename']    : '' ;
  2.         $filename    = $filename.=".txt";
Apr 17 '10 #4
nouras
15
you are welcome :)
Apr 17 '10 #5
Dormilich
8,658 Expert Mod 8TB
*gg* why so complicated?
Expand|Select|Wrap|Line Numbers
  1. $filename = (isset($_POST['filename'])) ? $_POST['filename'] . ".txt" : NULL;
Apr 17 '10 #6
gobblegob
133 100+
@Dormilich
Yeah that works too, Thanks.
Apr 17 '10 #7
Markus
6,050 Expert 4TB
@nouras
Variables are not case-insensitive in PHP. $_post should be $_POST.
Apr 18 '10 #8
nouras
15
@Markus
sure .....
thanx,your eyes also case-sensitive :)
Apr 18 '10 #9

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

Similar topics

4
by: megha | last post by:
Hi all I am exporting some data in .csv format through jsp file it is exporting the data in csv format but giving the exported file .jsp extension. I want .csv extension can anybody help. ...
1
by: Kevin Potter | last post by:
We have an application that has been running on IIS4 and IIS5 for quite some time, without problem We're now migrating to IIS6 (windows/2003), and have run into a what might? be a Javascipt...
3
by: Nate Hekman | last post by:
I have an aspx page that generates a file on the fly for a person to download. It sends these http headers: Content-Type: text/plain Content-Disposition: attachment; filename="myfile.lic" ...
8
by: Lad | last post by:
Hello, what is a way to get the the extension of a filename from the path? E.g., on my XP windows the path can be C:\Pictures\MyDocs\test.txt and I would like to get the the extension of the...
3
by: broli85 | last post by:
I am writing an extension for Firefox 1.5. I would like to know if there is a way to write and read data to and from a file which is in the location of the extension (or somewhere in the user's...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
1
by: J.P. | last post by:
I've developed a com extension for explorer and another dll linked to the com extension which provides the actual functionality. The extension does nothing more than create an object and pass...
12
by: Dave H. | last post by:
Please redirect me if this message is posted to the wrong group. Given the intention of delivering content to an HTTP user agent (such as Internet Explorer) which is to be immediately opened by...
8
by: Ron | last post by:
I am building a dynamic image loading class. I have a list of properties that have associated images in a specified directory. The problem they are multiple formats which are not known at...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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...

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.