Jump to content

upload file help


phierce

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

Link to comment
https://forums.phpfreaks.com/topic/3863-upload-file-help/
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]

Link to comment
https://forums.phpfreaks.com/topic/3863-upload-file-help/#findComment-13444
Share on other sites

Archived

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

×
×
  • Create New...

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.