spikypunker Posted January 15, 2009 Share Posted January 15, 2009 Hey Guys, im developing an online video showcase site, this is an extension of our main website. I've used a simple php file uploader before and am wondering if it would work in the same way nowadays due to global variables being turned off most servers? The method i would try would be: <?php if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { $filename = basename($_FILES['uploaded_file']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") && ($_FILES["uploaded_file"]["size"] < 350000)) { $newname = dirname(__FILE__).'/upload/'.$filename; if (!file_exists($newname)) { if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { echo "It's done! The file has been saved as: ".$newname; } else { echo "Error: A problem occurred during file upload!"; } } else { echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists"; } } else { echo "Error: Only .jpg images under 350Kb are accepted for upload"; } } else { echo "Error: No file uploaded"; } ?> Am i right in thinking this would not work anymore?? Any help muuuuch apperciated ) Peace Link to comment https://forums.phpfreaks.com/topic/140925-solved-html-form-to-php-file-uploader/ Share on other sites More sharing options...
ILMV Posted January 15, 2009 Share Posted January 15, 2009 $_FILE is a super global, they are not effected (correct me if I am wrong). But looking over your code I see no reason why it shouldn't work. ILMV Link to comment https://forums.phpfreaks.com/topic/140925-solved-html-form-to-php-file-uploader/#findComment-737598 Share on other sites More sharing options...
spikypunker Posted January 15, 2009 Author Share Posted January 15, 2009 haha genius, you're right it does work! Well what a waste of everybodies time! lol sorry guys! But at least this shows other people how to do a simple php uploader, and also that Super Global variables are still allowed on servers! I've learnt something anyway Cheers man. Link to comment https://forums.phpfreaks.com/topic/140925-solved-html-form-to-php-file-uploader/#findComment-737606 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.