Jump to content

Recommended Posts

I have an online gallery running. The code is sort of working and displays the error message, that is supposed to be echoed, ERROR:loadImage. I don't understand why. This should work. As i am new to this and used a tutorial i'm not sure how to solve the problem. Any suggestions

 

 

<?php
include("GallerySizer.php");
include("config.php");
DEFINE("IMAGE_FULL", '../photos/');

//database connect


$db_server ="db1125.oneandone.co.uk";     
$db_user = "dbo218351273";    $db_pass = "adawman291086";     
$db_name = "db218351273";
$con = mysql_connect("$db_server","$db_user","$db_pass");

// Album cover
$cover = $_FILES['image']['name'][$_POST['album_cover']];
if (!$_REQUEST['process']){
echo("Error! No images chosen for processing. <br />");
echo("Click <a href='index.php'>here</a> to start processing your images.");
die();
} elseif (!$_POST['album_id']){
echo("No album selected. Please <a href=\"\">choose an album</a> to upload images to.");
die();
} else {
for($i = 0; $i < count($_FILES['image']['tmp_name']); $i++){
	$fileName = $_FILES['image']['name'][$i];
	copy($_FILES['image']['tmp_name'][$i], IMAGE_FULL . $fileName);
	$thumb = new GallerySizer();
		if($thumb->getLocation(IMAGE_FULL . $fileName)){ 
		if($thumb->loadImage()){
		echo("Still here!");
			if($thumb->getSize()){
				if($thumb->setThumbnail()){
					if($thumb->copyThumbImage()){
						if($thumb->resizeImage())
						{
							$thumb->copyResizedImage();
						}else{die("ERROR:resizeImage");}
					}else{die("ERROR:copyThumbImage");}
				}else{die("ERROR:setThumbnail");}
			}else{die("ERROR:getSize");}
		}else{die("ERROR:loadImage");}
	}else{
		echo("Invalid image/file has been uploaded. Please upload a supported file-type (JPEG/PNG)"); 
		unlink(IMAGE_FULL . $fileName);
		die();
	}
	insert_location($thumb);
}
} 

function insert_location($thumb_obj)
{

$image_location = $thumb_obj->getImageLocation();
$thumb_location = $thumb_obj->getThumbLocation();

// If image matches cover selection, update album cover
if($cover == $_FILES['image']['name'][$i]){
	$sql = "UPDATE albums SET album_cover = '" . $thumb_location . "' WHERE album_id = " . $_POST['album_id'];
	$result = @mysql_query($sql) or die("Error inserting records: " . mysql_error());
}

mysql_select_db("db218351273", $con);
$sql = ("INSERT INTO photos (photo_id, photo_title, photo_desc, photo_date, photo_location, thumbnail_location,album_id) 
VALUES('0', '$_POST[photo_title]', '$_POST[photo_desc]', 'NOW()', '$image_location', '$thumb_location', '$_POST[album_id]')");
$result = mysql_query($sql) or die("Error inserting record(s) into the database: " . mysql_error());
if ($result){
	echo("Images successfully converted and stored! <br />Click <a href='index.html'>here</a> to continue.");
}
}

?>

Link to comment
https://forums.phpfreaks.com/topic/71328-solved-where-wont-my-file-upload/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.