doctorbill
asked on
php images and apache
The attached file works perfectly in my apache installation if I DO NOT add any image info in the following
All the info is entered into the database correctly
If I add the image path in the following then nothing is entered into the database
I assume it is a permissions issue:
-------------------------- ---------- --
All the info is entered into the database correctly
If I add the image path in the following then nothing is entered into the database
I assume it is a permissions issue:
--------------------------
$formfile = "";
if($_FILES['art_Thumb'] && $_FILES['art_Thumb']['size'] > 0){
$uploaddir = "images/artists/thumb/"; //folder in which to put the file
$ori_name = $_FILES[art_Thumb][name];
$tmp_name = $_FILES[art_Thumb][tmp_name];
$src = imagecreatefromjpeg($tmp_name);
list($width,$height) = getimagesize($tmp_name);
//landscape
if ($width >= $height) {
$pwidth = 450;
$newwidth = $pwidth;
$newheight = ($height/$width)*$pwidth;
}
//
//portrait
if ($height >= $width) {
$pwidth = $width;
$newheight = 450;
$newwidth = ($width/$height)*$newheight;
}
//
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$newfile = $uploaddir.$ori_name;
imagejpeg($tmp,$newfile,100);
chmod($newfile,0777);
}
$formfile1 = "";
if($_FILES['art_Large'] && $_FILES['art_Large']['size'] > 0){
$uploaddir1 = "images/artists/large/"; //folder in which to put the file
$ori_name_large = $_FILES[art_Large][name];
$tmp_name = $_FILES[art_Large][tmp_name];
$src = imagecreatefromjpeg($tmp_name);
list($width,$height) = getimagesize($tmp_name);
//landscape
if ($width >= $height) {
$pwidth = 900;
$newwidth = $pwidth;
$newheight = ($height/$width)*$pwidth;
}
//
//portrait
if ($height >= $width) {
$pwidth = $width;
$newheight = 900;
$newwidth = ($width/$height)*$newheight;
}
//
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$newfile_large = $uploaddir1.$ori_name_large;
imagejpeg($tmp,$newfile_large,100);
chmod($newfile_large,0777);
}
mysql_query("INSERT INTO art_gallery (artgal_LinkID, artgal_Name, artgal_Thumb, artgal_Large, artgal_Title, artgal_Com, artgal_com2, artgal_Med, artgal_sizeUnit, artgal_sp, artgal_sl, artgal_fsize, artgal_fsizep, artgal_fsizel, artgal_stat, artgal_Cost, artgal_Arc, artgal_Order, artgal_Group, artgal_GroupN) VALUES
(
'".$_POST[idlink]."',
'".$_POST[art_Nme]."',
'".$newfile."',
'".$newfile_large."',
'".$_POST[art_title]."',
'".$_POST[art_com]."',
'".$_POST[art_com2]."',
'".$_POST[art_med]."',
'".$selected_radio."',
'".$_POST[im_size_port]."',
'".$_POST[im_size_land]."',
'".$fselected_radio."',
'".$_POST[fim_size_port]."',
'".$_POST[fim_size_land]."',
'".$_POST[art_stat]."',
'".$_POST[art_cost]."',
'".$_POST[art_arc]."',
'".$_POST[arc_orderS]."',
'".$_POST[art_grp]."',
'".$selected_radio_grp."'
)
");
//thumbnail gallery insert
<?php
session_start();
include('connections/example_connect.php');
include('connections/example_functions.php');
require_once('administration/RAY_EE_config.php');
$uid = access_control();
if (!empty($_GET[artist_added])) {
$artadded = $_GET[artist_added];
record_set('artInfo',"SELECT artinf_Name FROM art_info WHERE artinf_Name = '$artadded' ");
}
record_set("artThumbsInf", "SELECT * FROM art_thumbs WHERE art_Name = '$artadded' ");
$imageadd = $_GET[image_added];
record_set("artgaladd", "SELECT * FROM art_gallery WHERE artgal_Title = '$imageadd' ");
$imad = " Image Added: ";
record_set("artNames", "SELECT * FROM art_info" );
$selname = urldecode($_GET[art_name]);
record_set("artists", "SELECT * FROM art_info WHERE artinf_Name = '$selname' ");
record_set("artgroups", "SELECT * FROM art_thumbs WHERE art_Name = '$selname' ");
$artistimageadded = $_GET[artist_added];
record_set("arcorder", "SELECT * FROM art_gallery WHERE artgal_Name = '$selname' ORDER BY artgal_Order DESC ");
record_set("groups", "SELECT * FROM art_gallery WHERE artgal_Name = '$selname' GROUP BY artgal_Group");
$added = "new images added for";
$space = " ";
$duplicate = $_GET[test];
$thumblink = $_POST[idlink];
//form insert
if ($_POST) {
if (!empty($_POST['idlink'])) {
$artlink = $_POST['idlink'];
record_set('thumblinkid',"SELECT * FROM art_thumbs WHERE art_IDlink = '".$artlink."' ");
}
//radio code
$selected_radio = $_POST['units'];
if ($selected_radio == 'cm') {
$cms_status = 'checked';
}
else if ($selected_radio == 'inches') {
$inches_status = 'checked';
}
//end radio code
//radio code framed
$fselected_radio = $_POST['funits'];
if ($fselected_radio == 'fcm') {
$fcms_status = 'checked';
}
else if ($fselected_radio == 'finches') {
$finches_status = 'checked';
}
//end radio code framed
//radio code groups
$selected_radio_grp = $_POST['grps'];
if ($selected_radio_grp == 'grp') {
$grps_status = 'checked';
}
//end radio code groups
//check to see if the 'title' already exists in the database
$titlecheck = $_POST['art_title'];
$check = mysql_fetch_row(mysql_query("SELECT * FROM art_gallery WHERE artgal_Title = '".addslashes($titlecheck)."'"));
if ($check[0]) {
//echo "Duplicate Title exists - Please use the Browser Back Arrow to go to the previous page";
header("Location: frm_artgallery.php?test=Duplicate-Title");
//$message = "(Duplicate Title Exists)";
//echo $message;
die;
}
//
$formfile = "";
if($_FILES['art_Thumb'] && $_FILES['art_Thumb']['size'] > 0){
$uploaddir = "images/artists/thumb/"; //folder in which to put the file
$ori_name = $_FILES[art_Thumb][name];
$tmp_name = $_FILES[art_Thumb][tmp_name];
$src = imagecreatefromjpeg($tmp_name);
list($width,$height) = getimagesize($tmp_name);
//landscape
if ($width >= $height) {
$pwidth = 450;
$newwidth = $pwidth;
$newheight = ($height/$width)*$pwidth;
}
//
//portrait
if ($height >= $width) {
$pwidth = $width;
$newheight = 450;
$newwidth = ($width/$height)*$newheight;
}
//
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$newfile = $uploaddir.$ori_name;
imagejpeg($tmp,$newfile,100);
chmod($newfile,0777);
}
$formfile1 = "";
if($_FILES['art_Large'] && $_FILES['art_Large']['size'] > 0){
$uploaddir1 = "images/artists/large/"; //folder in which to put the file
$ori_name_large = $_FILES[art_Large][name];
$tmp_name = $_FILES[art_Large][tmp_name];
$src = imagecreatefromjpeg($tmp_name);
list($width,$height) = getimagesize($tmp_name);
//landscape
if ($width >= $height) {
$pwidth = 900;
$newwidth = $pwidth;
$newheight = ($height/$width)*$pwidth;
}
//
//portrait
if ($height >= $width) {
$pwidth = $width;
$newheight = 900;
$newwidth = ($width/$height)*$newheight;
}
//
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$newfile_large = $uploaddir1.$ori_name_large;
imagejpeg($tmp,$newfile_large,100);
chmod($newfile_large,0777);
}
mysql_query("INSERT INTO art_gallery (artgal_LinkID, artgal_Name, artgal_Thumb, artgal_Large, artgal_Title, artgal_Com, artgal_com2, artgal_Med, artgal_sizeUnit, artgal_sp, artgal_sl, artgal_fsize, artgal_fsizep, artgal_fsizel, artgal_stat, artgal_Cost, artgal_Arc, artgal_Order, artgal_Group, artgal_GroupN) VALUES
(
'".$_POST[idlink]."',
'".$_POST[art_Nme]."',
'".$newfile."',
'".$newfile_large."',
'".$_POST[art_title]."',
'".$_POST[art_com]."',
'".$_POST[art_com2]."',
'".$_POST[art_med]."',
'".$selected_radio."',
'".$_POST[im_size_port]."',
'".$_POST[im_size_land]."',
'".$fselected_radio."',
'".$_POST[fim_size_port]."',
'".$_POST[fim_size_land]."',
'".$_POST[art_stat]."',
'".$_POST[art_cost]."',
'".$_POST[art_arc]."',
'".$_POST[arc_orderS]."',
'".$_POST[art_grp]."',
'".$selected_radio_grp."'
)
");
//thumbnail gallery insert
if ($_POST) {
mysql_query("UPDATE art_thumbs SET
art_Group = '".$selected_radio_grp."'
WHERE art_IDlink = ".$row_thumblinkid[art_IDlink]."
");
}
//end thumbnail gallery insert
$redirect
= 'frm_artgallery.php?'
. 'artist_added='
. urlencode($_POST['art_Nme'])
. '&'. 'image_added='
. urlencode($_POST['art_title'])
;
header('Location: '.$redirect); die;
}
//end form insert
?>
<!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=utf-8" />
<title>Lucy B Campbell Home Page</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<script src="jquery/jquery-1.8.3.min.js">
</script>
<script type="text/JavaScript">
jQuery(document).ready(function($) {
$("#art_arc").change(function(){
if($("#art_arc").val()=="Active"){
$("#art_stat").val("");
}
if($("#art_arc").val()=="Archived"){
$("#art_stat").val("Sold");
}
});
});
</script>
<script language="javascript" type="text/javascript">
function select_group()
{
var x = document.frmGeneral.art_group_sel.selectedIndex;
var selected_text = document.frmGeneral.art_group_sel.options[x].text;
document.frmGeneral.art_grp.value=selected_text;
}
</script>
<script type="text/JavaScript">
function selectOrder()
{
var x = document.frmGeneral.arc_order.selectedIndex;
var selected_text = document.frmGeneral.arc_order.options[x].text;
document.frmGeneral.arc_orderS.value=selected_text;
}
</script>
</head>
<body>
<?php require_once('incJScripts.php'); ?>
<?php require_once('incTinyMCE.html'); ?>
<div class="container" align="center">
<div class="header_container"<?php require_once('incPageHeader.php'); ?></div>
<div class="body_container" >
<div align="left" class="body_text_large"><a href="index.php" target="_parent">Home Page</a> :: <span class="body_text_large_brickred">Artists Gallery Additions (Artist must be in the database in order to add an image)</span></div>
<br /><br />
<form action="frm_artgallery.php" method="GET">
<div align="center"><span class="body_text_large">Select Artist Name (Required): </span>
<select name="art_name" id="art_name" onchange='this.form.submit();'>
<option value="value">Artist Name:</option>
<?php do { ?>
<option <?php if ($_GET[art_name] == $row_artNames['artinf_Name']) { ?>selected="selected"<?php } ?> value="<?php echo urlencode($row_artNames['artinf_Name']); ?>"><?php echo $row_artNames['artinf_Name']?></option>
<?php } while ($row_artNames = mysql_fetch_assoc($artNames)); ?>
</select>
</div>
</form>
<form action="frm_artgallery.php" enctype="multipart/form-data" name="frmGeneral" id="frmGeneral" method="post">
<table width="675" border="0" align="center" cellpadding="0" class="">
<tr>
<td colspan="5" align="left" class="body_text_large"><a href="administration.php">Administration Page</a>: <span class="loggedin"><?php echo $_SESSION[loggedin]; ?></span></td>
<tr>
<td width="12" colspan="2" align="left">
<a href="logout.php" target="_parent"><span class="loggedout">LOGOUT</span></a> </td>
</tr>
<tr><td colspan="2"></tr>
<tr>
<td colspan="5"><hr width="200" size="1" /><br /><br /></td>
</tr>
<tr>
<td nowrap="nowrap" class="body_text_large"> </td>
<td class="body_text_large"><div align="right"><a href="artist_thumbnails.php?artist=<?php echo $artistimageadded; ?>">
<?php if (!empty($artistimageadded )) {echo "Link to database images for current Artist";} ?></a><?php if (!empty($artistimageadded )) {echo $imad;} ?><?php if(!empty($artistimageadded )) { ?>
<img src="<?php echo $row_artgaladd[artgal_Thumb]; ?>" width="150"/> <?php } ?></div></td>
</tr>
<tr>
<td><br /><br /></td>
</tr>
<tr>
<td nowrap="nowrap" class="body_text_large"> </td>
<td class="body_text_large" align="left">New Images will be added for Artist: <span class="body_text_message_artist"><?php echo $row_artists[artinf_Name]; ?><?php if(!empty($artistimageadded )) {
echo $added.$space.$artistimageadded; } ?></span></td>
</tr>
<tr>
<td nowrap="nowrap" class="body_text_large" align="left"><label>Artist Name: </label></td>
<td class="body_text_large" align="left"><input name="art_Nme" type="text" id="art_Nme" size="50" value="<?php echo $row_artists[artinf_Name]; ?>" readonly="readonly"/></td>
</tr>
<tr>
<td nowrap="nowrap" class="body_text_large" align="left">Thumbnail Image: </td>
<td class="body_text_large" align="left"><input name="art_Thumb" type="file" id="art_Thumb" size="50" /></td>
</tr>
<tr>
<td nowrap="nowrap" class="body_text_large" align="left">Large Image: </td>
<td class="body_text_large" align="left"><input name="art_Large" type="file" id="art_Large" size="50" /></td>
</tr>
<tr>
<td nowrap="nowrap" class="body_text_large" align="left">Image Title: </td>
<td class="body_text_large" align="left"><input name="art_title" type="text" id="art_title" size="50" class="validate[required] text-input "/><span class="error_message"><?php echo $duplicate; ?></span></td>
</tr>
<tr>
<td class="body_text_large" align="left"><label>Image Editions: </label></td>
<td class="body_text_large" align="left"><input name="art_com" type="text" class="" id="art_com" size="50" /></td>
</tr>
<tr>
<td nowrap="nowrap" class="body_text_large" align="left"><label>Image Com. 2: </label></td>
<td class="body_text_large" align="left"><input name="art_com2 :" type="text" id="art_com2" size="50" /></td>
</tr>
<tr>
<td nowrap="nowrap" class="body_text_large" align="left"><label>Image Medium: </label></td>
<td class="body_text_large" align="left"><input name="art_med" type="text" id="art_med" size="50" /></td>
</tr>
<tr>
<td valign="top" class="body_text_large" align="left"><label>Image Size:</label></td>
<td class="body_text_large" align="left"><label> Portrait: <input name="im_size_port" type="text" id="im_size_port" size="6" class="validate[required] text-input" />
</label>
<label> Landscape: <input name="im_size_land" type="text" id="im_size_land" size="6" class="validate[required] text-input" />
<input type="radio" name="units" id="cms" value="cm" class="validate[condRequired[im_size_port]] text-input" />
cm
</label>
<input type="radio" name="units" id="inches" value="inches" class="validate[condRequired[im_size_land]] text-input"
<?php if (!empty($row_artgaladd[artgal_sizeUnit])) { ?>
checked="checked" <?php } ?> />
inches
<span class="body_text">(decimals please)</span></td>
</tr>
<tr>
<td valign="top" class="body_text_large" align="left"><label>Framed Size:</label></td>
<td class="body_text_large" align="left"><label> Portrait: <input name="fim_size_port" type="text" id="fim_size_port" size="6" class="" />
</label>
<label> Landscape: <input name="fim_size_land" type="text" id="fim_size_land" size="6" class="" />
<input type="radio" name="funits" id="fcms" value="cm" class="" />
cm
</label>
<input type="radio" name="funits" id="finches" value="inches" class=""
<?php if (!empty($row_artgaladd[artgal_fsize])) { ?>
checked="checked" <?php } ?> />
inches
<span class="body_text">(decimals please)</span></td>
</tr>
<tr>
<td valign="top" class="body_text_large" align="left"><label>Status: </label></td>
<td class="body_text_large" align="left"><label>
<select name="art_stat" id="art_stat">
<option value=""></option>
<option value="Sold" <?php if ($row_artgaladd[artgal_stat] == 'Sold') echo ' selected="selected"'; ?>>Sold</option>
</select>
</label> <label>Image Status:</label><label>
<select name="art_arc" id="art_arc">
<option value=""></option>
<option value="Active" <?php if ($row_artgaladd[artgal_Arc] == 'Active') echo ' selected="selected"'; ?>>Active</option>
<option value="Archived" <?php if ($row_artgaladd[artgal_Arc] == 'Archived') echo ' selected="selected"'; ?>>Archived</option>
<option value="Deleted" <?php if ($row_artgaladd[artgal_Arc] == 'Deleted') echo ' selected="selected"'; ?>>Deleted</option>
</select>
</label> <label>Archive Order:</label>
<input name="arc_orderS" id="arc_orderS" type="text" size="1" value="<?php echo $row_artists[artgal_Order]; ?>" />
<select name="arc_order" id="arc_order" onChange="selectOrder()">
<option value=""></option>
<?php do { ?>
<option <?php if ($row_arcorder[artgal_Order] == $row_arcorder['artgal_Order']) { ?>selected="selected"<?php } ?> value="<?php echo $row_arcorder['artgal_Order']; ?>"><?php echo $row_arcorder['artgal_Order']; ?></option>
<?php } while ($row_arcorder = mysql_fetch_assoc($arcorder)); ?>
</select>
</td>
</tr>
<tr>
<td valign="top" class="body_text_large" align="left"><label>Groups:</label></td>
<td class="body_text_large" align="left"><input name="art_grp" type="text" id="art_grp" size="15" />
<select name="art_group_sel" id="art_group_sel" onchange="select_group()" >
<option value=""></option>
<?php do { ?>
<option <?php if ($row_groups['artgal_Group'] == $row_groups['artgal_Group']) { ?>selected="selected"<?php } ?> value="<?php echo $row_groups['artgal_Group']; ?>"><?php echo $row_groups['artgal_Group']?></option>
<?php } while ($row_groups = mysql_fetch_assoc($groups)); ?>
</select>
<input type="radio" name="grps" id="grp" value="1" class=""
<?php if (!empty($row_artgroups[art_Group])) { ?>
checked="checked" <?php } ?>
/> Activated (If activated, select a group)</td>
</tr>
<tr>
<td valign="top" class="body_text_large" align="left">Cost:</td>
<td class="body_text_large" align="left"><input name="art_cost" type="text" id="art_cost" size="10" /></td>
</tr>
<tr>
<td colspan="2" align="right" class="body_text_large"><label>
<input type="hidden" name="idlink" id="idlink" value="<?php echo $row_artists[link_ID] ?>" />
<input type="submit" name="button" id="button" value="Submit" />
</label></td>
</tr>
</table>
</form><br />
</div><br /><br /><br /><br />
<div class="body_hr"><hr size="1">
<div class="body_text" align="left"><?php require_once('incPageFooter.php'); ?></div>
</div>
</body>
</html>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
As usual
Perfect example and 100%
Thanks a million
Perfect example and 100%
Thanks a million
ASKER
Solution
Thanks for the points -- it's a great question! ~Ray
ASKER
Thanks for the info
I have carried out some tests and if I make the initial file I am uploading much smaller (< 1 mb) it then works with the script I posted
Is there some limiting factor in the script / apache server ?