Hello.
I created a php code to upload image, make the treatmant and unlink it, but save a thumbnail and a normal imagem, but the source image I unlink.
The code is below:
<?php
include('../config.php');
$link = mysql_connect("$DBServer","$DBUser", "$DBPass");
mysql_select_db("$DSN");
$fotoId = $_REQUEST['fotoId'];
$Id = $_REQUEST['Id'];
if(isset($fotoId)) {
//Definido prioridades
$tmp_name = $_FILES["pictures"]["$tmp_name"];
$name = $_FILES["pictures"]["name"];
$path = "/home/restricted/home/xxx/public_html/admin/upimage/";
$nome_unico = md5(uniqid($name));
//Setando permissão de passagem
$seleciona = explode(".",$name);
if (($seleciona[1] == gif) || ($seleciona[1] == jpg)) {
//Fazendo UpLoad do arquivo ao servidor
copy($tmp_name,$path.$nome_unico.".".$seleciona[1]);
if ($seleciona[1] == gif) {
$starting_image = imagecreatefromgif("/home/restricted/home/xxx/public_html/admin/upimage/".$nome_unico."."$seleciona[1]);
} else {
$starting_image = imagecreatefromjpeg("/home/restricted/home/xxx/public_html/admin/upimage/".$nome_unico."."$seleciona[1]);
}
$width = imagesx($starting_image);
$height = imagesy($starting_image);
//Criando o thumbnail
$thumb_width = 65;
$constant = $width/$thumb_width;
$thumb_height = round($height/$constant, 0);
$thumb_image = imagecreatetruecolor($thumb_width, $thumb_height);
imagecopyresampled($thumb_image, $starting_image, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height);
$path_thumb = "/home/restricted/home/xxx/public_html/admin/upimage/thumb/";
imagejpeg($thumb_image, $path_thumb.$nome_unico);
//Criando a imagem em tamanho grande/real
$thumb_width = 530;
$constant = $width/$thumb_width;
$thumb_height = round($height/$constant, 0);
$thumb_image = imagecreatetruecolor($thumb_width, $thumb_height);
imagecopyresampled($thumb_image, $starting_image, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height);
$path_tratada = "/home/restricted/home/xxx/public_html/admin/upimage/tratada/";
imagejpeg($thumb_image, $path_tratada.$nome_unico);
//Salvando dados no Banco
$fotoSize = $_FILES["pictures"]["size"];
$sql = mysql_query("INSERT INTO scm_galerias(fotoNome, fotoSize, fotoId) values ('$nome_unico','$fotoSize','$fotoId')",$link)or die("morreu");
unlink("/home/restricted/home/xxx/public_html/admin/upimage/".$nome_unico);
echo "Sucesso";
echo "<br />";
echo "ID da foto: $fotoId";
?>
<script language="JavaScript">
location.href="up_image.php?fotoId=<?php echo "$fotoId";?>&Id=<? echo "$barcoId"; ?>";
</script>
<?
} else {
?>
<script language="JavaScript">
location.href="up_image.php?fotoId=<?php echo "$fotoId";?>&Id=<? echo "$barcoId"; ?>&msg=Tipo de Imagem não permitida";
</script>
<?
}
}
?>
The problem is, that the script don´t work, it´s not doing the upload to the server, and my server don´t accepet move_uploaded_file just copy.
Can someone help me???
Sorry for my bad english, and thanks a lot!