Jump to content


Photo

upload file help


  • Please log in to reply
3 replies to this topic

#1 phierce

phierce
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 01 March 2006 - 09:56 PM

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



#2 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 02 March 2006 - 01:07 AM

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:

  $xtenshun = getFileExtension($yourfile);

  $xtenshun = strtolower($xtenshun);

  if ($xtenshun != "txt")

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


PHP Ninja

#3 phierce

phierce
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 02 March 2006 - 04:35 PM

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.

#4 Boerke

Boerke
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 02 March 2006 - 05:34 PM

check the tutorials on this site, there is one about file uploading




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users