payney Posted October 26, 2007 Share Posted October 26, 2007 Hello all, What I am wanting to do, is upload a css via a webpage to the directory /css/ Now, I know I need a form, but what is the php to put something in a directory? I havent a clue! Thanks Sam Quote Link to comment https://forums.phpfreaks.com/topic/74852-uploading-a-css-to-a-directory/ Share on other sites More sharing options...
subcool Posted October 26, 2007 Share Posted October 26, 2007 That should work if (move_uploaded_file($_FILES['userfile']['tmp_name'], "/home/user/somedir/" . basename($_FILES['userfile']['name'])) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; } Quote Link to comment https://forums.phpfreaks.com/topic/74852-uploading-a-css-to-a-directory/#findComment-378487 Share on other sites More sharing options...
payney Posted October 27, 2007 Author Share Posted October 27, 2007 Thanks for that, but how do I only allow to upload css. This dosnt work, it works with images and php files, but not when its a css type. if (!$uploaded_type =="text/css") { echo "CSS files<br>"; $ok=0; } Quote Link to comment https://forums.phpfreaks.com/topic/74852-uploading-a-css-to-a-directory/#findComment-379198 Share on other sites More sharing options...
LiamProductions Posted October 27, 2007 Share Posted October 27, 2007 something like this: if ( file extension of file is equal to css ) { upload } else { Overload! } Quote Link to comment https://forums.phpfreaks.com/topic/74852-uploading-a-css-to-a-directory/#findComment-379205 Share on other sites More sharing options...
payney Posted October 27, 2007 Author Share Posted October 27, 2007 ANy idea what the thingy is for file extsention? Quote Link to comment https://forums.phpfreaks.com/topic/74852-uploading-a-css-to-a-directory/#findComment-379206 Share on other sites More sharing options...
payney Posted October 30, 2007 Author Share Posted October 30, 2007 Anyone? I cant get this working. Quote Link to comment https://forums.phpfreaks.com/topic/74852-uploading-a-css-to-a-directory/#findComment-381020 Share on other sites More sharing options...
aschk Posted October 30, 2007 Share Posted October 30, 2007 You should be testing $_FILES['userfile']['type'] to see whether you want the file or not. If in doubt do a few sample tests and echo out the type to see what it thinks the css files you're giving it are. Quote Link to comment https://forums.phpfreaks.com/topic/74852-uploading-a-css-to-a-directory/#findComment-381033 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.