PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have this upload file code, independently i can run this file but when i what to add in my codes, it doesn't work. What issue should i aware of and and if my codes already have form tag, which part should i paste this code to make sure that it runs? My concern is
<?php if ( isset($_FILES['file1']) ) {
$name = $_FILES['file1']['name'];
$source = $_FILES['file1']['tmp_name'];
$target = "PATH_TO_FOLDER";
if ( @is_uploaded_file($_FILES['file1']['tmp_name']) ) {
$timo = @move_uploaded_file( $source, $target );
}
if ( !$timo ) {
$error = $_FILES['file1']['error'];
if ( $error == 2 ) { $name = $_FILES['file1']['name'];
$msg1 = "$name is to large to upload";
}
else {
$msg1 = "No file has been selected for upload. A default image will be used.";
}
}
else {
$img1 = $_FILES['file1']['name'];
$msg1 = "<b>$img1</b> has been uploaded.";
} ?>
You also don't have a value for ><input type="hidden" name="MAX_FILE_SIZE" value="????"> which means any file up to 2mb can be uploaded without a problem. What isn't shown in the example is to check for file types when uploading.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering