...

View Full Version : crop picture



jacque99
11-04-2010, 12:28 PM
Hello everyone,
In fact, I have a script that makes the crop image that works well, I'm stuck on the part of adding a text box to allow to name the image "thumb".
I also ask if possible to remove the "PHP_SELF" script and divide it into several pages.
Attached script

mlseim
11-04-2010, 04:08 PM
If you have them upload the photo and a caption (or photo title) on a form,
someplace, you have to save the caption and point it to the photo. That will
require some sort of database (either plain text or MySQL).

Do you have any databases already installed and you are using?

jacque99
11-04-2010, 04:39 PM
n fact I'm using a MySql database with PHP, and I have no problem in this side.
When I make a text box to enter a name for the resized image.
The easiest for me is to divide my script in several forms and removes the action = "<? Php echo $ _SERVER [" PHP_SELF "];?>".
The problem is when I make a text box and I give a new name, it gives me always errors.

winracer
11-04-2010, 04:44 PM
are you wanting the text box to be the name of the uploadfile? or are you wanting a text box above the save button and name the save file?

jacque99
11-04-2010, 04:55 PM
Enter the name of 'thumb_image_name' in a text box:

<form name="photo" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"];?>" method="post">
Photo <input type="file" name="image" size="30" /> <br /><br />

Specify the name of 'thumb_image_name' <input type="text" name="thumb"><br /><br />

<input type="submit" name="upload" value="Upload" /><br /><br />
</form>





After


$thumb=$_POST['thumb'];
$thumb_image_name = $thumb.".jpg";

mlseim
11-04-2010, 05:31 PM
oh, so you're wanting to rename the file that they are uploading?

They pick the photo from their PC, and then type in a name,
that name becomes the JPG filename ... is that correct?

jacque99
11-04-2010, 05:34 PM
exactly :)

mlseim
11-04-2010, 05:38 PM
I have to ask why you would allow that?

People could be entering all kinds of things that should not be in a filename.

Maybe you want that textbox or "caption" to appear under the photo?
Why are you making it the filename?

jacque99
11-04-2010, 05:41 PM
to allow me to rank my pictures by the following name

mlseim
11-04-2010, 05:42 PM
Does rank mean "sort"?

You want to be able to sort them alphabetically?

jacque99
11-04-2010, 05:45 PM
yes exactly, but it later.
now I'm doing a space admin to insert pictures with the name I want.

jacque99
11-04-2010, 06:07 PM
Now I think you understand, is that you have an idea or a piece of code?

mlseim
11-04-2010, 06:28 PM
That's why I asked about the database.

Normally, when a file is uploaded, a row is added to the database
that specifies the filename, some sort of ID, a description, a title, gallery number, etc.

Your web pages use that database to display the photos.

They could be sorted by ID, title, description ... etc.
And you could specify which photos appear in which gallery.

What is your website about, and what is the existing MySQL used for?


.

jacque99
11-04-2010, 06:30 PM
I can take care of this part, I just how to get a false name in the textbox and give this name to the image
Thank you

DrDOS
11-04-2010, 06:34 PM
I can take care of this part, I just how to get a false name in the textbox and give this name to the image
Thank youWhy not just put the thumbnails in a thumbs folder? That would eliminate the renaming and make it easier to call them since they would have the same name as the original.

jacque99
11-04-2010, 06:37 PM
I will like to do as I explained before.
I think I explained well, and I always get an answer

MattF
11-04-2010, 06:40 PM
The problem is when I make a text box and I give a new name, it gives me always errors.

Those errors would be...?

jacque99
11-04-2010, 06:43 PM
If you take my script and test yourself, you can see that the name entered in tex box, it is not considered

winracer
11-04-2010, 07:47 PM
off the top of my head I start with something like





<?php

//Constants
//You can alter these options

/*

$nomImage=$_POST['nomImage'];
$thumb_image_name = $nomImage.".jpg";
*/

$upload_dir = "upload_pic"; // Le répertoire pour les images à enregistrer dans
$upload_path = $upload_dir."/"; // Le chemin d'accès de l'endroit où l'image sera enregistrée
$large_image_name = "resized_pic.jpg"; // Nouveau nom de la grande image
//$thumb_image_name = "thumbnail_pic.jpg"; // Nouveau nom de l'image miniature
//$thumb_image_name = $_POST['name'].".jpg";
$thumb = $_GET["id"];




$thumb_image_name = $thumb.".jpg";


$max_file = "1148576"; // Environ 1MB
$max_width = "500"; // Largeur maximum autorisée pour l'image en grand
$thumb_width = "100"; // Largeur de la vignette
$thumb_height = "100"; // Hauteur de la vignette

//Fonctions Image
//Vous n'avez pas besoin de modifier ces fonctions
function resizeImage($image,$width,$height,$scale) {
$newImageWidth = ceil($width * $scale);
$newImageHeight = ceil($height * $scale);
$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
$source = imagecreatefromjpeg($image);
imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height);
imagejpeg($newImage,$image,90);
chmod($image, 0777);
return $image;
}
//Vous n'avez pas besoin de modifier ces fonctions
function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale){
$newImageWidth = ceil($width * $scale);
$newImageHeight = ceil($height * $scale);
$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
$source = imagecreatefromjpeg($image);
imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$ width,$height);
imagejpeg($newImage,$thumb_image_name,90);
chmod($thumb_image_name, 0777);
return $thumb_image_name;
}
//Vous n'avez pas besoin de modifier ces fonctions
function getHeight($image) {
$sizes = getimagesize($image);
$height = $sizes[1];
return $height;
}
//Vous n'avez pas besoin de modifier ces fonctions
function getWidth($image) {
$sizes = getimagesize($image);
$width = $sizes[0];
return $width;
}

//Emplacements des images
$large_image_location = $upload_path.$large_image_name;
$thumb_image_location = $upload_path.$thumb_image_name;

//Créer le répertoire de téléchargement avec les autorisations droit si elle n'existe pas
if(!is_dir($upload_dir)){
mkdir($upload_dir, 0777);
chmod($upload_dir, 0777);
}

//Vérifiez pour voir si des images avec le même nom existe déjà
if (file_exists($large_image_location)){
if(file_exists($thumb_image_location)){
$thumb_photo_exists = "<img src=\"".$upload_path.$thumb_image_name."\" alt=\"Thumbnail Image\"/>";
}else{
$thumb_photo_exists = "";
}
$large_photo_exists = "<img src=\"".$upload_path.$large_image_name."\" alt=\"Large Image\"/>";
} else {
$large_photo_exists = "";
$thumb_photo_exists = "";
}

if (isset($_POST["upload"])) {
//Obtenez les informations de fichier
$userfile_name = $_FILES['image']['name'];
$userfile_tmp = $_FILES['image']['tmp_name'];
$userfile_size = $_FILES['image']['size'];
$filename = basename($_FILES['image']['name']);
$file_ext = substr($filename, strrpos($filename, '.') + 1);


//Ne traiter que si le fichier est un fichier JPG et en dessous de la limite permise
if((!empty($_FILES["image"])) && ($_FILES['image']['error'] == 0)) {
if (($file_ext!="jpg") && ($userfile_size > $max_file)) {
$error= "ONLY jpeg images under 1MB are accepted for upload";
}
}else{
$error= "Select a jpeg image for upload";
}
//Tout est ok, donc on peut télécharger l'image.
if (strlen($error)==0){

if (isset($_FILES['image']['name'])){

move_uploaded_file($userfile_tmp, $large_image_location);
chmod($large_image_location, 0777);

$width = getWidth($large_image_location);
$height = getHeight($large_image_location);
//Redimensionnez l'image si elle est supérieure à la largeur définie ci-dessus
if ($width > $max_width){
$scale = $max_width/$width;
$uploaded = resizeImage($large_image_location,$width,$height,$scale);
}else{
$scale = 1;
$uploaded = resizeImage($large_image_location,$width,$height,$scale);
}
//Supprimez le fichier miniature afin que l'utilisateur peut créer un nouveau
if (file_exists($thumb_image_location)) {
unlink($thumb_image_location);
}
}
//Actualisez la page pour voir la nouvelle image transféré
header("location:".$_SERVER["PHP_SELF"]."?id=".$_POST[thumb]);
exit();
}
}

if (isset($_POST["upload_thumbnail"]) && strlen($large_photo_exists)>0) {
//Recevez les nouvelles coordonnées pour recadrer l'image
$x1 = $_POST["x1"];
$y1 = $_POST["y1"];
$x2 = $_POST["x2"];
$y2 = $_POST["y2"];
$w = $_POST["w"];
$h = $_POST["h"];
//Échelle de l'image à l'thumb_width énoncés ci-dessus
$scale = $thumb_width/$w;
$cropped = resizeThumbnailImage($thumb_image_location, $large_image_location,$w,$h,$x1,$y1,$scale);

//Recharger la page à nouveau pour afficher la vignette
header("location:".$_SERVER["PHP_SELF"]."?id=".$_GET["id"]);
exit();
}

if ($_GET['a']=="delete"){
if (file_exists($large_image_location)) {
unlink($large_image_location);
}
if (file_exists($thumb_image_location)) {
unlink($thumb_image_location);
}
header("location:".$_SERVER["PHP_SELF"]."?id=".$_GET["id"]);
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Crop image</title>
<script type="text/javascript" src="js/jquery-pack.js"></script>
<script type="text/javascript" src="js/jquery.imgareaselect-0.3.min.js"></script>
</head>
<body>


<?php
//Seul l'affichage javacript si une image a été transféré
if(strlen($large_photo_exists)>0){
$current_large_image_width = getWidth($large_image_location);
$current_large_image_height = getHeight($large_image_location);?>
<script type="text/javascript">
function preview(img, selection) {
var scaleX = <?php echo $thumb_width;?> / selection.width;
var scaleY = <?php echo $thumb_height;?> / selection.height;

$('#thumbnail + div > img').css({
width: Math.round(scaleX * <?php echo $current_large_image_width;?>) + 'px',
height: Math.round(scaleY * <?php echo $current_large_image_height;?>) + 'px',
marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
marginTop: '-' + Math.round(scaleY * selection.y1) + 'px'
});
$('#x1').val(selection.x1);
$('#y1').val(selection.y1);
$('#x2').val(selection.x2);
$('#y2').val(selection.y2);
$('#w').val(selection.width);
$('#h').val(selection.height);
}

$(document).ready(function () {
$('#save_thumb').click(function() {
var x1 = $('#x1').val();
var y1 = $('#y1').val();
var x2 = $('#x2').val();
var y2 = $('#y2').val();
var w = $('#w').val();
var h = $('#h').val();
if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){
alert("You must make a selection first");
return false;
}else{
return true;
}
});
});

$(window).load(function () {
$('#thumbnail').imgAreaSelect({ aspectRatio: '1:1', onSelectChange: preview });
});

</script>
<?php }?>
<h1>Photo Upload and Crop</h1>
<?php
//message d'erreur d'affichage s'il ya des
if(strlen($error)>0){
echo "<ul><li><strong>Error!</strong></li><li>".$error."</li></ul>";
}
if(strlen($large_photo_exists)>0 && strlen($thumb_photo_exists)>0){
echo "<p><strong>NOTE:</strong> If the thumbnail image looks the same as the previous one, just hit refresh a couple of times.</p>";
echo $large_photo_exists."&nbsp;".$thumb_photo_exists;
echo "<p><a href=\"".$_SERVER["PHP_SELF"]."?a=delete\">Delete Images</a></p>";
}else{
if(strlen($large_photo_exists)>0){?>
<h2>Créer une miniature</h2>
<div align="center">
<img src="<?php echo $upload_path.$large_image_name;?>" style="float: left; margin-right: 10px;" id="thumbnail" alt="Create Thumbnail" />
<div style="float:left; position:relative; overflow:hidden; width:<?php echo $thumb_width;?>px; height:<?php echo $thumb_height;?>px;">
<img src="<?php echo $upload_path.$large_image_name;?>" style="position: relative;" alt="Thumbnail Preview" />
</div>
<br style="clear:both;"/>
<form name="thumbnail" action="<?php echo $_SERVER["PHP_SELF"]."?id=".$_GET["id"];?>" method="post">
<input type="hidden" name="x1" value="" id="x1" />
<input type="hidden" name="y1" value="" id="y1" />
<input type="hidden" name="x2" value="" id="x2" />
<input type="hidden" name="y2" value="" id="y2" />
<input type="hidden" name="w" value="" id="w" />
<input type="hidden" name="h" value="" id="h" />

<input type="submit" name="upload_thumbnail" value="Save Thumbnail" id="save_thumb" />
</form>
</div>
<hr />

<?php } ?>

<?php


}



if($_GET['id'] == "")

{


?>
Enter the name of 'thumb_image_name' in a text box:

<form name="photo" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]."?id=".$_POST[thumb];?>" method="post">
Photo <input type="file" name="image" size="30" /> <br /><br />


Specify the name of 'thumb_image_name' <input type="text" name="thumb"><br /><br />

<input type="submit" name="upload" value="Upload" /><br /><br />
</form>


<?php }



else{}
?>


</body>
</html>




Winracer
Jack of all trades master of none :eek:
http://www.helpmewithperl.com:D
http://www.myfunnypets.com (http://www.myfunnypetsl.com):D


“Only a life lived for others is a life worth while” Albert Einstein
“The golden rule for every business man is this: 'Put yourself in your customer’s place'” Orison Swett Marden
“No person was ever honored for what he received; honor has been the reward for what he gave” Calvin Coolidge

jacque99
11-05-2010, 11:11 AM
I still have the same problem, here is the new name. "Jpg"
it's like $ thumb = $ _GET ["id"] is empty

MattF
11-05-2010, 12:11 PM
Looking at that code winracer posted, your post var is incorrect. Your input is called thumb, not name:



$thumb_image_name = $_POST['name'].".jpg";



Should be:



$thumb_image_name = $_POST['thumb'].".jpg";


Also, ditch this and do it correctly:



<form name="photo" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]."?id=".$_POST[thumb];?>" method="post">


No need to add the name as a get var when it's already in the form, and PHP_SELF should be encoded, if you insist upon using an exploitable method.

jacque99
11-05-2010, 12:23 PM
Here is the full script with your modification, but not always work



<?php

//Constants
//You can alter these options



$upload_dir = "upload_pic"; // Le répertoire pour les images à enregistrer dans
$upload_path = $upload_dir."/"; // Le chemin d'accès de l'endroit où l'image sera enregistrée
$large_image_name = "resized_pic.jpg"; // Nouveau nom de la grande image
$thumb_image_name = $_POST['thumb'].".jpg";
$max_file = "1148576"; // Environ 1MB
$max_width = "500"; // Largeur maximum autorisée pour l'image en grand
$thumb_width = "100"; // Largeur de la vignette
$thumb_height = "100"; // Hauteur de la vignette

//Fonctions Image
//Vous n'avez pas besoin de modifier ces fonctions
function resizeImage($image,$width,$height,$scale) {
$newImageWidth = ceil($width * $scale);
$newImageHeight = ceil($height * $scale);
$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
$source = imagecreatefromjpeg($image);
imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height);
imagejpeg($newImage,$image,90);
chmod($image, 0777);
return $image;
}
//Vous n'avez pas besoin de modifier ces fonctions
function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale){
$newImageWidth = ceil($width * $scale);
$newImageHeight = ceil($height * $scale);
$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
$source = imagecreatefromjpeg($image);
imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$ width,$height);
imagejpeg($newImage,$thumb_image_name,90);
chmod($thumb_image_name, 0777);
return $thumb_image_name;
}
//Vous n'avez pas besoin de modifier ces fonctions
function getHeight($image) {
$sizes = getimagesize($image);
$height = $sizes[1];
return $height;
}
//Vous n'avez pas besoin de modifier ces fonctions
function getWidth($image) {
$sizes = getimagesize($image);
$width = $sizes[0];
return $width;
}

//Emplacements des images
$large_image_location = $upload_path.$large_image_name;
$thumb_image_location = $upload_path.$thumb_image_name;

//Créer le répertoire de téléchargement avec les autorisations droit si elle n'existe pas
if(!is_dir($upload_dir)){
mkdir($upload_dir, 0777);
chmod($upload_dir, 0777);
}

//Vérifiez pour voir si des images avec le même nom existe déjà
if (file_exists($large_image_location)){
if(file_exists($thumb_image_location)){
$thumb_photo_exists = "<img src=\"".$upload_path.$thumb_image_name."\" alt=\"Thumbnail Image\"/>";
}else{
$thumb_photo_exists = "";
}
$large_photo_exists = "<img src=\"".$upload_path.$large_image_name."\" alt=\"Large Image\"/>";
} else {
$large_photo_exists = "";
$thumb_photo_exists = "";
}

if (isset($_POST["upload"])) {
//Obtenez les informations de fichier
$userfile_name = $_FILES['image']['name'];
$userfile_tmp = $_FILES['image']['tmp_name'];
$userfile_size = $_FILES['image']['size'];
$filename = basename($_FILES['image']['name']);
$file_ext = substr($filename, strrpos($filename, '.') + 1);


//Ne traiter que si le fichier est un fichier JPG et en dessous de la limite permise
if((!empty($_FILES["image"])) && ($_FILES['image']['error'] == 0)) {
if (($file_ext!="jpg") && ($userfile_size > $max_file)) {
$error= "ONLY jpeg images under 1MB are accepted for upload";
}
}else{
$error= "Select a jpeg image for upload";
}
//Tout est ok, donc on peut télécharger l'image.
if (strlen($error)==0){

if (isset($_FILES['image']['name'])){

move_uploaded_file($userfile_tmp, $large_image_location);
chmod($large_image_location, 0777);

$width = getWidth($large_image_location);
$height = getHeight($large_image_location);
//Redimensionnez l'image si elle est supérieure à la largeur définie ci-dessus
if ($width > $max_width){
$scale = $max_width/$width;
$uploaded = resizeImage($large_image_location,$width,$height,$scale);
}else{
$scale = 1;
$uploaded = resizeImage($large_image_location,$width,$height,$scale);
}
//Supprimez le fichier miniature afin que l'utilisateur peut créer un nouveau
if (file_exists($thumb_image_location)) {
unlink($thumb_image_location);
}
}
//Actualisez la page pour voir la nouvelle image transféré
header("location:".$_SERVER["PHP_SELF"]."?id=".$_POST[thumb]);
exit();
}
}

if (isset($_POST["upload_thumbnail"]) && strlen($large_photo_exists)>0) {
//Recevez les nouvelles coordonnées pour recadrer l'image
$x1 = $_POST["x1"];
$y1 = $_POST["y1"];
$x2 = $_POST["x2"];
$y2 = $_POST["y2"];
$w = $_POST["w"];
$h = $_POST["h"];
//Échelle de l'image à l'thumb_width énoncés ci-dessus
$scale = $thumb_width/$w;
$cropped = resizeThumbnailImage($thumb_image_location, $large_image_location,$w,$h,$x1,$y1,$scale);

//Recharger la page à nouveau pour afficher la vignette
header("location:".$_SERVER["PHP_SELF"]."?id=".$_GET["id"]);
exit();
}

if ($_GET['a']=="delete"){
if (file_exists($large_image_location)) {
unlink($large_image_location);
}
if (file_exists($thumb_image_location)) {
unlink($thumb_image_location);
}
header("location:".$_SERVER["PHP_SELF"]."?id=".$_GET["id"]);
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Crop image</title>
<script type="text/javascript" src="js/jquery-pack.js"></script>
<script type="text/javascript" src="js/jquery.imgareaselect-0.3.min.js"></script>
</head>
<body>


<?php
//Seul l'affichage javacript si une image a été transféré
if(strlen($large_photo_exists)>0){
$current_large_image_width = getWidth($large_image_location);
$current_large_image_height = getHeight($large_image_location);?>
<script type="text/javascript">
function preview(img, selection) {
var scaleX = <?php echo $thumb_width;?> / selection.width;
var scaleY = <?php echo $thumb_height;?> / selection.height;

$('#thumbnail + div > img').css({
width: Math.round(scaleX * <?php echo $current_large_image_width;?>) + 'px',
height: Math.round(scaleY * <?php echo $current_large_image_height;?>) + 'px',
marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
marginTop: '-' + Math.round(scaleY * selection.y1) + 'px'
});
$('#x1').val(selection.x1);
$('#y1').val(selection.y1);
$('#x2').val(selection.x2);
$('#y2').val(selection.y2);
$('#w').val(selection.width);
$('#h').val(selection.height);
}

$(document).ready(function () {
$('#save_thumb').click(function() {
var x1 = $('#x1').val();
var y1 = $('#y1').val();
var x2 = $('#x2').val();
var y2 = $('#y2').val();
var w = $('#w').val();
var h = $('#h').val();
if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){
alert("You must make a selection first");
return false;
}else{
return true;
}
});
});

$(window).load(function () {
$('#thumbnail').imgAreaSelect({ aspectRatio: '1:1', onSelectChange: preview });
});

</script>
<?php }?>
<h1>Photo Upload and Crop</h1>
<?php
//message d'erreur d'affichage s'il ya des
if(strlen($error)>0){
echo "<ul><li><strong>Error!</strong></li><li>".$error."</li></ul>";
}
if(strlen($large_photo_exists)>0 && strlen($thumb_photo_exists)>0){
echo "<p><strong>NOTE:</strong> If the thumbnail image looks the same as the previous one, just hit refresh a couple of times.</p>";
echo $large_photo_exists."&nbsp;".$thumb_photo_exists;
echo "<p><a href=\"".$_SERVER["PHP_SELF"]."?a=delete\">Delete Images</a></p>";
}else{
if(strlen($large_photo_exists)>0){?>
<h2>Créer une miniature</h2>
<div align="center">
<img src="<?php echo $upload_path.$large_image_name;?>" style="float: left; margin-right: 10px;" id="thumbnail" alt="Create Thumbnail" />
<div style="float:left; position:relative; overflow:hidden; width:<?php echo $thumb_width;?>px; height:<?php echo $thumb_height;?>px;">
<img src="<?php echo $upload_path.$large_image_name;?>" style="position: relative;" alt="Thumbnail Preview" />
</div>
<br style="clear:both;"/>
<form name="thumbnail" action="<?php echo $_SERVER["PHP_SELF"]."?id=".$_GET["id"];?>" method="post">
<input type="hidden" name="x1" value="" id="x1" />
<input type="hidden" name="y1" value="" id="y1" />
<input type="hidden" name="x2" value="" id="x2" />
<input type="hidden" name="y2" value="" id="y2" />
<input type="hidden" name="w" value="" id="w" />
<input type="hidden" name="h" value="" id="h" />

<input type="submit" name="upload_thumbnail" value="Save Thumbnail" id="save_thumb" />
</form>
</div>
<hr />

<?php } ?>

<?php


}



if($_GET['id'] == "")

{


?>
Enter the name of 'thumb_image_name' in a text box:



<form name="photo" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]."?id=".$_POST[thumb];?>" method="post">


Photo <input type="file" name="image" size="30" /> <br /><br />


Specify the name of 'thumb_image_name' <input type="text" name="thumb"><br /><br />

<input type="submit" name="upload" value="Upload" /><br /><br />
</form>


<?php }



else{}
?>


</body>
</html>

MattF
11-05-2010, 12:30 PM
Granted, I'm only scanning your code, but this section:



if($_GET['id'] == "")

{


?>
Enter the name of 'thumb_image_name' in a text box:



<form name="photo" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]."?id=".$_POST[thumb];?>" method="post">


Photo <input type="file" name="image" size="30" /> <br /><br />


Specify the name of 'thumb_image_name' <input type="text" name="thumb"><br /><br />

<input type="submit" name="upload" value="Upload" /><br /><br />
</form>


Where is the $_POST['thumb'] processing done in the code? I noted none offhand. For you to be renaming the image, something has to be processing that request and changing the respective name for the thumbnail. If you're planning on making it part of your crop/upload process and not a separate thing, then integrate it into your upload form.

jacque99
11-05-2010, 12:37 PM
I did not understand what you mean.

winracer
11-05-2010, 03:15 PM
just add something like this to make sure text box not empty



if((empty($_POST["thumb"])) && ($_POST['thumb']['error'] == 0)) {

$error= "Please Enter Name To Upload A Image";
}
else{
}

jacque99
11-05-2010, 04:23 PM
It always crashes, I wonder if you can test the script in your machine to understand the error.
Thank you

winracer
11-05-2010, 04:55 PM
It always crashes, I wonder if you can test the script in your machine to understand the error.
Thank you

I tested this one at http://myfunnypets.com/crop_image/

and it works ok

jacque99
11-05-2010, 05:19 PM
Can I please have the complete script by email
jacque99@hotmail.fr

winracer
11-05-2010, 05:26 PM
Can I please have the complete script by email
jacque99@hotmail.fr

on it's way..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum