Uploading Files

A

Anonymous

Guest
Ok, whats wrong with this, it ONLY uploads jpg files, i thought i was the daddy at first but it only works for jpgs, want it to work for ALL of the files!!!!

<?

if (is_uploaded_file($attach) != '')

{

copy($attach, "Uploads/$attach_name");

}

?>
 
AaaDee said:
Ok, whats wrong with this, it ONLY uploads jpg files, i thought i was the daddy at first but it only works for jpgs, want it to work for ALL of the files!!!!

Code:
<?

if (is_uploaded_file($attach) != '')

{

copy($attach, "Uploads/$attach_name");

}


?>


may be...
Code:
<?
if (is_uploaded_file($attach))
{
copy($attach, "Uploads/$attach_name");
}
 
AaaDee said:
Ok, whats wrong with this, it ONLY uploads jpg files, i thought i was the daddy at first but it only works for jpgs, want it to work for ALL of the files!!!!

<?

if (is_uploaded_file($attach) != '')

{

copy($attach, "Uploads/$attach_name");

}

?>

Hi there!
It's most popularity mistakes of beginner programmer on PHP.
And will best if you using file size.... etc.
Cause PHP and MIME working together.
Code:
<form enctype="multipart/form-data" action="_URL_" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
See this code, and try make some like this (from manual of PHP).

or this:
Code:
<?php 
// In PHP earlier then 4.1.0, $HTTP_POST_FILES  should be used instead of $_FILES.
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
    copy($_FILES['userfile']['tmp_name'], "/place/to/put/uploaded/file");
} else {
    echo "Possible file upload attack. Filename: " . $_FILES['userfile']['name'];
}
/* ...or... */
move_uploaded_file($_FILES['userfile']['tmp_name'], "/place/to/put/uploaded/file");
?>
 
Code:
<? 
if (is_uploaded_file($attach))  // if you trensfer file and file exist this runction return - TRUE 
{ 
// and this code will execute
copy($attach, "Uploads/$attach_name"); 
}
>

may be you have error in the other plece of your script...[/code]
 
Back
Top