phierce Posted March 1, 2006 Share Posted March 1, 2006 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.TXTis this possible? can anyone show me the code or where to find it? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/3863-upload-file-help/ Share on other sites More sharing options...
Caesar Posted March 2, 2006 Share Posted March 2, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/3863-upload-file-help/#findComment-13444 Share on other sites More sharing options...
phierce Posted March 2, 2006 Author Share Posted March 2, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/3863-upload-file-help/#findComment-13588 Share on other sites More sharing options...
Boerke Posted March 2, 2006 Share Posted March 2, 2006 check the tutorials on this site, there is one about file uploading Quote Link to comment https://forums.phpfreaks.com/topic/3863-upload-file-help/#findComment-13612 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.