$masir=$_POST['masir'];
$post_text=$_POST['post_text'];
$myfile = fopen("newfile.php", "w") or die("Unable to open file!");
fwrite($myfile, $post_text);
fclose($myfile);
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
// Check if file already exists
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
?>
$_FILES["fileToUpload"]["tmp_name"]
name of file= /tmp/nuvNjf54U
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
} else {
echo "File is not an image.";
}
}
echo "mime= ".$check["mime"];
mime= image/jpeg
echo "<table border=\"1\">";
echo "<tr><td>Client Filename: </td>
<td>" . $_FILES["fileToUpload"]["name"] . "</td></tr>";
echo "<tr><td>File Type: </td>
<td>" . $_FILES["fileToUpload"]["type"] . "</td></tr>";
echo "<tr><td>File Size: </td>
<td>" . ($_FILES["fileToUpload"]["size"] / 1024) . " Kb</td></tr>";
echo "<tr><td>Name of Temp File: </td>
<td>" . $_FILES["fileToUpload"]["tmp_name"] . "</td></tr>";
echo "</table>";
if ( $_FILES["fileToUpload"]["type"] == "image/jpeg") echo"your file is jpeg";
Array ( [0] => 667
[1] => 184
[2] => 3
[3] => width="667" height="184"
[bits] => 8
[mime] => image/png )
if ($_FILES["fileToUpload"]["type"]=="image/jpeg" )
rename($target_file, "../f".$number.".jpg");
if ($_FILES["fileToUpload"]["type"]=="image/png" )
rename($target_file, "../f".$number.".png");
if ($_FILES["fileToUpload"]["type"]=="image/gif" )
rename($target_file, "../f".$number.".gif");
$my_loci=$_SERVER['SERVER_NAME'];
$link1="http://".$my_loci."/folder1/folder2" ;
if ($_FILES["fileToUpload"]["type"]=="image/jpeg" )
{
rename($target_file, "../f".$number.".jpg");
$link2=$link1."/f".$number.".jpg";
} // jpg
if ($_FILES["fileToUpload"]["type"]=="image/png" )
{
rename($target_file, "../f".$number.".png");
$link2=$link1."/f".$number.".png";
} // png
if ($_FILES["fileToUpload"]["type"]=="image/gif" )
{
rename($target_file, "../f".$number.".gif");
$link2=$link1."/f".$number.".gif";
} // gif
echo"<br>";
echo $link2;
echo"[Img]".$link2."[/Img]";
if ($_FILES["fileToUpload"]["type"]=="image/jpeg" )
{
if ($my_option==1){
$pattern = "/.jpe?g/i";
$cleaned_base_name=preg_replace($pattern, "", $base_name);
rename($target_file, "../".$cleaned_base_name."_n".$number.".jpg");
$link2=$link1."/".$cleaned_base_name."_n".$number.".jpg";
} // option1
if ($my_option==2){
rename($target_file, "../n".$number.".jpg");
$link2=$link1."/n".$number.".jpg";
} // option=2
} // jpg
<input type="checkbox" name="demoCheckBox" value="1">
<?php
if (isset($_POST['demoCheckBox'])) {
// Checkbox is checked
// Perform actions or logic for checked checkbox
} else {
// Checkbox is not checked
// Perform actions or logic for unchecked checkbox
}
?>