Jump to content

Archived

This topic is now archived and is closed to further replies.

phierce

upload file help

Recommended Posts

I have a question about uploading a file. I have the code to upload a file and it works, but I need something a little different.

What I am working on is a script to read a txt file and manipulate it. I got all that working but I would like to be able to do 2 things...

1 - I would like to allow only .txt files to be uploaded.

2 - I would like the file to be saved not only to a certain directory but named as a certain file. for example if they upload a file SOMEFILENAME.TXT I would like to be able to save it as ANOTHERFILENAME.TXT

is this possible? can anyone show me the code or where to find it? Thanks

Share this post


Link to post
Share on other sites
If you're new to PHP, it wouldn't be much help to just "show you the code".

On topic...You can do this to make sure only .txt files are uploaded:

[code]
  $xtenshun = getFileExtension($yourfile);

  $xtenshun = strtolower($xtenshun);

  if ($xtenshun != "txt")

  {print"<center>Only Text Files Are Allowed, You Schmuck.</center>";exit();}[/code]

Share this post


Link to post
Share on other sites
Thanks!! that helps, I figured that would be the easy part.

Im not technically "new" to php, I have been dabbling with it a while I am just not pro at it.

thanks again.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.