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!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi guys,
I have an upload form upload_form.html with a browse button and a field for the image name. The image is retrieved and saved with upload.php which calls test.cropinterface.php so the user can crop and save the uploaded image. However, when I pass the image variable from upload.php to test.cropinterface.php by $_GET['filename'], the filename will be displayed when I use echo $filename, but when I try to use a save or copy function, the error message lets me know that it cannot recognize an empty string. Please see my code for test.cropinterface.php below. Global variables is on and I am using a newer version of php.
<?php
header("Pragma: no-cache");
header('cache-control: no-store, must revalidate');
require('class.cropinterface.php')
$ci =& new CropInterface(true);
//this pass and variable call works
$filename=$_GET['filename'];
echo $filename;
if(isset($_GET['file'])
{
$ci->loadImage($_GET['file'];
//this pass and variable call does not work, but loadImage function does
//$filename=$_GET['filename'];
//echo $filename;
$ci->cropTo Dimensions($GET_['sx']. $GET_['sy'], $GET_['ex'], $GET_['ey']);
//this works and saves the cropped image to a relative path
$ci->saveImage("images/cropped.jpg", 100);
//this does not work and the error message states that it can't recognize filetype '../../Images/Thumbnails/Assemblages_Thumbs/'.
$ci->saveImage("../../Images/Thumbnails/Assemblages_Thumbs/".$filename, 100);
// I also tried
//$ci->saveImage("../../Images/Thumbnails/Assemblages_Thumbs/$filename",100);
//or
//copy("images/cropped.jpg", "../../Images/Thumbnails/Assemblages_Thumbs/".$filename);
}
?>
I guess the error means that the variable must be empty. However if I put "../../Images/Thumbnails/Assemblages_Thumbs/new.jpg" instead of "../../Images/Thumbnails/Assemblages_Thumbs/".$filename it works
I have been trying to get my head through this wall for the past 2 weeks. Its only gotten my headaches. So it would be soo great if someone would see what I am doing wrong here.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Sorry for using the CODE instead of the PHP tag. I visit the w3 websites often to look for tutorials, but I actually know how to save an uploaded file. This time I couldn't find any help or code samples for this specific problem. Maybe if I provide more code you can understand better.
<?php
$filename = basename($_FILES['uploaded']['name']);
//... some other code
switch($mimetype) {
case "image/jpg":
case "image/jpeg":
case "image/pjpeg":$ok=1;
break;
case "image/gif": $ok=1;
break;
case "image/png": $ok=1;
break;
}
//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
echo "Sorry your file was not uploaded<br>";
}
//If everything is ok we try to upload it to different folders and to uploaded_image.jpg
//This works perfectly
if($ok==1)
{
$uploadfile="./Image_Upload/cropcanvas/images/uploaded_image.jpg";
move_uploaded_file($_FILES['uploaded']['tmp_name'], $uploadfile);
}
///*********************
///THIS IS THE CRUCIAL QUESTION. Am I doing something wrong when I pass $filename to test.cropinterface.php (please see first post)
///**********************
header("location:Image_Upload/cropcanvas/test.cropinterface.php?filename=$filename". "&assem=$assem_folder&collab=$collab_folder&jazz=$jazz_folder&". "paint=$paint_folder&paper=$paper_folder&new=$new_folder");
?>
As said before I can echo the filename when I fetch $filename in test.cropinterface.php, but I cannot save it with my save() or copy() function, which I know have worked before. The variable appears to be empty. Could it be that other uses of $_GET (e.g. $_GET['file']) alter the assigned $filename variable?[/list]
You have a space in your method call. Shouldn't it be cropToDimensions?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
And your $GET_ variables should be $_GET (underscore before GET)
Also, I believe that should be a comma (,) and not a period (.) after $_GET['sx'] parameter of that method.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
You have a space in your method call. Shouldn't it be cropToDimensions?
That function actually works. I got the class and script from Andrew Collington http://www.phpclasses.org. Its a great little script and brought me only joy and happiness.
However, something is wrong with my variable, because I cannot even copy with the regular copy() function from an existing file to the path + filename variable.
You have a space in your method call. Shouldn't it be cropToDimensions?
That function actually works. I got the class and script from Andrew Collington http://www.phpclasses.org. Its a great little script and brought me only joy and happiness.
However, something is wrong with my variable, because I cannot even copy with the regular copy() function from an existing file to the path + filename variable.