Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.