Friday, 16 March 2012

Q: Which function use file upload.


Q: Which function use file upload.
Or
Q: How can know file upload or not upload.
Or
Q: Whats Key word use in form tag when upload file on server.
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']).
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}
Also Check file upload or not upload this keywords
file_existsChecks whether a file or directory exists.
<?php
$filename 
'/path/to/foo.txt';
if (
file_exists($filename)) {
    echo 
"The file $filename exists";
} else {
    echo 
"The file $filename does not exist";
}
?>
If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return true/FALSE.
$_file[] attributes
$_FILES["pictures"]["error"]
$_FILES["pictures"]["name"]
$_FILES["pictures"]["type"]
$_FILES["pictures"]["type"]
$_FILES["userfile"]["tmp_name"]

No comments:

Post a Comment