Hi, 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:
This code ain't working. HELP
7
Hi,
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:
Please let me know if you got it to work.
Thanks,
Josh
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:
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
- PeerFly
- mywebwork
- jamespitt
- Jawshh
- [1] reply
- Sharpscrew
- saschakimmel
Next Topics on Trending Feed
-
7