This code ain't working. HELP
I have a file upload php script but everytime I hit the upload button on my form, it says that the file I chose isn't allowed. I restricted some file types for security. Here's the code:
<?php $allowed_filetypes = array('.jpg','.gif','.bmp','.png','.jar'); $max_filesize = 524288; $upload_path = './files/'; $filename = $_FILES['userfile']['name']; $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large.'); if(!is_writable($upload_path)) die('You cannot upload to the specified directory, please CHMOD it to 777.'); // Upload the file to your specified path. if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)) echo 'Your file upload was successful, view the file <a href="' . $upload_path . $filename . '" title="Your File">here</a>'; else echo 'There was an error during the file upload. Please try again.'; ?>
Thanks,
Josh
Case Studies | Follow Along Campaigns | Campaign Optimization
Get your totally free outsourcing guide here..
Send me a PM if you want to hire top-calibre outsourced staff.
Get a Website Loaded With Unique Content Every Month For Free. Check it out NOW!!!
Advanced Internet Marketing Tactics
** Get my ViralListMachine software now for free and build your own list virally by giving away free stuff @ http://www.virallistmachinegiveaway.com **