else show the html that have the upload input and an input bbox if i want to change the name
it takes the image name and type
if the text is empry then it use the upload name else it use the name from the text."the file type"
and it copy to a folder name photos/
then i got a resizer that resize the foto that i use it for thumb
there i have and if statment that
Code: Select all
if($file_type == "image/jpeg" || $file_type == "image/jpg")
{
$src = imagecreatefromjpeg($uploadedfile); }
else
if($file_type == "image/png")
{
$src = imagecreatefrompng($uploadedfile);
}
else
if($file_type == "image/gif")
{
$src = imagecreatefromgif($uploadedfile);
}
else
{
echo "I Dont allow <_". $file_type."_> images";
}
if it is jpg-png-bmp-jif is how me errors anyone that can help?
Code: Select all
<?php
if($_POST['submit'])
{
//perno tto name ths photo
$file_name = $HTTP_POST_FILES['ufile']['name'];
$file_type = $HTTP_POST_FILES['ufile']['type'];
//to onoma ths eikonas
$new_name = $_POST['name'];
if($new_name == "")
{
$new_file_name = $file_name;
}
else
{
$new_file_name=$new_name.filetype;
}
//dialego to path p tha th valo
$path= "photos/".$new_file_name;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "File Name : ".$new_file_name;
}
else
{
echo "Error";
}
}
if($file_type == "image/jpeg" || $file_type == "image/jpg")
{
$src = imagecreatefromjpeg($uploadedfile);
}
else
if($file_type == "image/png")
{
$src = imagecreatefrompng($uploadedfile);
}
else
if($file_type == "image/gif")
{
$src = imagecreatefromgif($uploadedfile);
}
else
{
echo "I Dont allow <_". $file_type."_> images";
}
echo "<br>".$file_type;
// This is the temporary file created by PHP
$uploadedfile = $file_name;
// Create an Image from it so we can do the resize
// Capture the original size of the uploaded image
list($width,$height)=getimagesize($uploadedfile);
// For our purposes, I have resized the image to be
// 600 pixels wide, and maintain the original aspect
// ratio. This prevents the image from being "stretched"
// or "squashed". If you prefer some max width other than
// 600, simply change the $newwidth variable
$newwidth=150;
$newheight=($height/$width)* $newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
// this line actually does the image resizing, copying from the original
// image into the $tmp image
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
// now write the resized image to disk. I have assumed that you want the
// resized, uploaded image file to reside in the ./images subdirectory.
$filename = "thumbs/". $uploadedfile;
imagejpeg($tmp,$filename,100);
}
else
{
?>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<form action="import.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<input name="ufile" type="file" id="ufile" size="29" /><br>
<input name="name" type="text" id="name" size="29" />
<input name="submit" type="submit" class="buttons" id="submit" value="Submit" />
</form>
<?php
}
?>