Copy Problem
Moderator: General Moderators
-
chris12295
- Forum Contributor
- Posts: 113
- Joined: Sun Jun 09, 2002 10:28 pm
- Location: USA
- Contact:
Copy Problem
I have an image gallery. User selects image, it copies to a tmp directory, make a thumbnail into photos/thumbs, then copies tmp image to photos folder.
Now lets say we have a folder with 2 jpg images. In my case, one would work perefectly but the other wouldnt copy to the tmp directory.
What could be causing this?
Now lets say we have a folder with 2 jpg images. In my case, one would work perefectly but the other wouldnt copy to the tmp directory.
What could be causing this?
-
chris12295
- Forum Contributor
- Posts: 113
- Joined: Sun Jun 09, 2002 10:28 pm
- Location: USA
- Contact:
copy function:
form code:
Names of files that don't work: April302003002.jpg, CourtneyVehnekampWebsitePhoto#1, February232003-Sweet16etc.073.jpg, February232003-Sweet16etc.081.jpg, Bonnie019.jpg, Bonnie021.jpg, Bonnie024.jpg, Bonnie075.jpg, Bonnie086.jpg
files that do work: BillCosbyPhoto.jpg, CourtneyVehnekamp.jpg
also, i just noticed that the two that work dont have numbers and all the rest do??
Code: Select all
function add_pic()
{
$tmp_name =
if(empty($_FILES[pic][name]))
{
$error = 1;
$GLOBALS[pic_message] = 'Please select a (.JPG) file';
}
if(!$error)
{
echo $_FILES[pic][tmp_name];
$dir = $_SERVER["DOCUMENT_ROOT"]."/Courtney/admin/tmp/";
$newname = "pic".time().".jpg";
$newfile = $dir . $newname;
copy($_FILES[pic][tmp_name], $newfile);
$dimensions = getimagesize($newfile)or die("Error");
if($dimensions[2] != 2)
{
$error = 1;
$GLOBALS[pic_message] = "Only use files with .JPG extensions.";
}
}
if(!$error)
{
$width = $dimensions[0];
$height = $dimensions[1];
$query = mysql_query("SELECT id from pics");
while($row=mysql_fetch_array($query))
{
$src = $row[id];
}
$src +=1;
$c = imagecreatefromjpeg($newfile);
/*y=height x=width*/
$dst_width=(($width*70)/$height);
if($dimensions[2] == 2)
{
$b = imagecreatetruecolor($dst_width, 70);
$ext = "JPG";
}
if($ext == "JPG")
{
imagecopyresampled($b, $c, 0, 0, 0, 0, $dst_width, 70, $width, $height);
copy($newfile, "../images/photos/$src.jpg");
imagejpeg($b, "../images/photos/thumbs/$src.jpg", 100);
}
mysql_query("INSERT into pics (src) VALUES($src)");
$_REQUEST[pic]='';
if(file_exists($newfile)) unlink($newfile);
}
else
{
include("add_pic.php");
die;
}
}Code: Select all
<form enctype="multipart/form-data" action="index.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="99999">
<input type="hidden" name="process" value="add_pic">
<table>
<tr><td colspan=3><span class='head1'>Add Picture</span></td></tr>
<tr><td bgcolor="#CCCCCC"><b class='form_text'>Picture File:</b> </td><td bgcolor="#999999"><input type="file" name="pic"></td><td bgcolor="#FFFFFF"><span class="error_message"><?=$GLOBALSїpic_message]?></span></td></tr>
<tr><td bgcolor="#CCCCCC"><b class='form_text'>Add Another Picture:</b> </td> <td bgcolor="#999999"><span class="form_text">Yes</span><input type="checkbox" name="page" value="add_pic" <?if(!empty($_REQUESTїpage]) and !empty($_REQUESTїsubmit])) echo "CHECKED";?>></td><td bgcolor="#FFFFFF"><img src="../images/interface/spacer.gif"></td></tr>
<tr><td colspan=2 align='center'><input name="submit" type="submit" value="Add Picture"></td></tr>
</table>
</form>files that do work: BillCosbyPhoto.jpg, CourtneyVehnekamp.jpg
also, i just noticed that the two that work dont have numbers and all the rest do??
-
chris12295
- Forum Contributor
- Posts: 113
- Joined: Sun Jun 09, 2002 10:28 pm
- Location: USA
- Contact:
well i tried that, i renemaed the april one to April.jpg but it still didnt work.
Then i copied the picture in one that didnt work to one that did, then the one that worked didnt work anymore.
So, could it be affected by the image size, resolution or the way it was saved i.e(Baseline standard, progressive...)?
i have max_upload_file size set to 10000M in my file, is that the right format?
is there a resolution setting?
Then i copied the picture in one that didnt work to one that did, then the one that worked didnt work anymore.
So, could it be affected by the image size, resolution or the way it was saved i.e(Baseline standard, progressive...)?
i have max_upload_file size set to 10000M in my file, is that the right format?
is there a resolution setting?
-
chris12295
- Forum Contributor
- Posts: 113
- Joined: Sun Jun 09, 2002 10:28 pm
- Location: USA
- Contact:
hey
doesnt this look wrong feyd:
shouldn't it be more like this:
Code: Select all
if(file_exists($newfile)) unlink($newfile);
}
else
{
include("add_pic.php");
die;
}
}Code: Select all
if(file_exists($newfile)) unlink($newfile) { <-- added bracket got rid of semi colon
} else {
include("add_pic.php");
die;
}
} <-- may not need this one-
chris12295
- Forum Contributor
- Posts: 113
- Joined: Sun Jun 09, 2002 10:28 pm
- Location: USA
- Contact: