Log in

View Full Version : Image Upload Issue



Titan85
04-20-2007, 08:01 PM
Hello, I am trying to get my image upload script to work, but it keeps giving the error, here is the code:
function uploadPic() {
$path = 'team_pics/';
$uploadpath = $path.basename($_FILES['imgfile']['name']);

if (!move_uploaded_file($_FILES['imgfile']['tmp_name'], $uploadpath)) {
die ('Error uploading the file!');
}

$img_name = "$path".$_FILES['imgfile']['name'];
$imageName = $_FILES['imgfile']['name'];
list($width, $height) = getimagesize($img_name);
$new_name = "team_pics/thum_".$_FILES['imgfile']['name'];
$newImage = "thum_".$_FILES['imgfile']['name'];

$new_width = 155;
$new_height = 90;

$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($img_name);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($image_p, $new_name, 100);
echo 'image uploaded';
}It keeps throwing out the "Error uploading the file!" error. Any idea why? Thanks

boxxertrumps
04-20-2007, 08:30 PM
try:

move_uploaded_file($_FILES['imgfile']['tmp_name'], $uploadpath) or die ('Error uploading the file!');

If that doesn't work the files might already exist, or the folder doesn't exist.

Titan85
04-21-2007, 03:10 PM
Ok, I got it working, it was an error with the path. Thanks for the help