I am newbie in PHP.
I compiled below PHP codes to re-size images in two size and it works great.
My Question
I need to save the uploaded image paths in MySQL database.
Paths
1) path to small image
2) path to big image
This is the codes
<?php
error_reporting(0);
$change="";
$abc="";
define ("MAX_SIZE","400");
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
$errors=0;
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$image =$_FILES["file"]["name"];
$uploadedfile = $_FILES['file']['tmp_name'];
if ($image)
{
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{
$change='<div class="msgdiv">Unknown Image extension </div> ';
$errors=1;
}
else
{
$size=filesize($_FILES['file']['tmp_name']);
if ($size > MAX_SIZE*1024)
{
$change='<div class="msgdiv">You have exceeded the size limit!</div> ';
$errors=1;
}
if($extension=="jpg" || $extension=="jpeg" )
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension=="png")
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
}
else
{
$src = imagecreatefromgif($uploadedfile);
}
echo $scr;
list($width,$height)=getimagesize($uploadedfile);
$newwidth=150;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
$newwidth1=50;
$newheight1=($height/$width)*$newwidth1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);
$filename = "profile.pic/profile/big" .date('Y-m-d_His - '). $_FILES['file']['name'];
$filename1 = "profile.pic/header/small".date('Y-m-d_His - '). $_FILES['file']['name'];
imagejpeg($tmp,$filename,100);
imagejpeg($tmp1,$filename1,100);
imagedestroy($src);
imagedestroy($tmp);
imagedestroy($tmp1);
}}
}
//If no errors registred, print the success message
if(isset($_POST['Submit']) && !$errors)
{
// mysql_query("update {$prefix}users set img='$big',img_small='$small' where user_id='$user'");
$change=' <div class="msgdiv">Image Uploaded Successfully!</div>';
}
?>
This is the Form
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"><head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta content="en-us" http-equiv="Content-Language">
<title>picture demo</title>
<link href="file:///C|/Users/Rameen/Downloads/.css" media="screen, projection" rel="stylesheet" type="text/css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<style type="text/css">
.help
{
font-size:11px; color:#006600;
}
body {
color: #000000;
background-color:#999999 ;
background:#999999 url(<?php echo $user_row['img_src']; ?>) fixed repeat top left;
font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
}
.msgdiv{
width:759px;
padding-top:8px;
padding-bottom:8px;
background-color: #fff;
font-weight:bold;
font-size:18px;-moz-border-radius: 6px;-webkit-border-radius: 6px;
}
#container{width:763px;margin:0 auto;padding:3px 0;text-align:left;position:relative; -moz-border-radius: 6px;-webkit-border-radius: 6px; background-color:#FFFFFF;}</style>
</head><body>
<div align="center" id="err">
<?php echo $change; ?> </div>
<div id="space"></div>
<div id="container" >
<div id="con">
<table width="502" cellpadding="0" cellspacing="0" id="main">
<tbody>
<tr>
<td width="500" height="238" valign="top" id="main_right">
<div id="posts">
<img src="<?php echo $filename; ?>" /> <img src="<?php echo $filename1; ?>" />
<form method="post" action="" enctype="multipart/form-data" name="form1">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><Td style="height:25px"> </Td></tr>
<tr>
<td width="150"><div align="right" class="titles">Picture
: </div></td>
<td width="350" align="left">
<div align="left">
<input size="25" name="file" type="file" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10pt" class="box"/>
</div></td>
</tr>
<tr><Td></Td>
<Td valign="top" height="35px" class="help">Image maximum size <b>400 </b>kb</span></Td>
</tr>
<tr><Td></Td><Td valign="top" height="35px"><input type="submit" id="mybut" value=" Upload " name="Submit"/></Td></tr>
<tr>
<td width="200"> </td>
<td width="200"><table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200" align="center"><div align="left"></div></td>
<td width="100"> </td>
</tr>
</table></td>
</tr>
</table>
</form>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body></html>
Any help will be appreciated.
You should try move_uploaded_file function for both the images. Create two sepearte directories in your server and loop through both files and use the move_uploaded_file.
Also create two fields in your database for storing both paths. and dump both parts in it.
$path='upload/'.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'] , $path);
mysql_query("insert into tablename (filepath) values('$path')");
Question: I need to save the uploaded image paths in MySQL database
And you have directories already so I think to will need to write a database query for this.
$yourDir = "path to your directory";
$completePathtoYourFile = $yourDir . "/" . $imageName . ".jpg"; //do not append .jpg if already.
Find how to connect to a mysql database. DB CONNECTION
$insert = "INSERT INTO table_name (field1, field2) VALUES ('$completePathtoYourFile', .......) ";
$result = mysqli_query($connectionVariable, $insert);
if(!$result){
echo "Not Inserted..";
}
else{
echo "Saved..";
}
As mentioned by other people you need to move the uploaded file from the temporary storage to a dir who's path is your $yourDir.
Related
I'm trying to use "greenlight.png" on the image in the corresponding table row only if the row value matches the value from my local file. I'm getting the $live_link value via:
<?php
$live_link_file = 'PIProjectSwitcher/live_link.php';
$f = fopen($live_link_file, 'r');
if ($f) {
$live_link = fread($f, filesize($live_link_file));
fclose($f);
}
?>
My PHP table is generated via:
<table width="700" border="1">
<tbody>
<tr bgcolor="#E0E0E0" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif; font-size: small; text-align: center;"><td width="660" height="35" align="left" valign="middle">Package Name</td><td width="40" height="35">Live</td><td width="40" height="35">Ready</td><td width="40" height="35">Edit Mode</td></tr>
<?php
if ($insight_packages_list = opendir('Insight_Packages/')) {
while (false !== ($entry = readdir($insight_packages_list))) {
if ($entry != "." && $entry != ".." && $entry != "Blank-Package") {
echo "<tr valign=\"middle\">
<div class=\"floatleft\"><td height=\"25\" style=\"font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif; font-size: large;\">{$entry}</div></td>
<td height=\"25\" align=\"center\">
<img src=\"images/$live$ready\" class=\"floatcenter\" width=\"25px\" height=\"25px\" id=\"$entry\" name=\"$entry\" /></td>
<td height=\"25\" align=\"center\"><img src=\"images/$live$ready\" class=\"floatcenter\" width=\"25px\" height=\"25px\" /></td>
<td height=\"25\" align=\"center\"> </td>
</tr>";
}
}
closedir($insight_packages_list);
}
?>
</tbody>
</table>
The final result looks like:
The table results are looking at my local directory and one of those directories will always match the value from the live_link.php file.
I'm hoping there's a way to set a group of variables and apply them to that specific matching table row, but I don't know how to do that.
Here is what I have so far:
<?php
if ($live_link == $entry) {
$live = 'greenlight.png';
$ready = 'greylight.png';
$editmode = 'locked.png';
} else {
$live = '';
$ready = '';
$editmode = '';
}
if ($live_link != $entry) {
$live = 'greylight.png';
$ready = 'greenlight.png';
$editmode = 'locked.png';
} else {
$live = '';
$ready = '';
$editmode = '';
}
?>
UPDATE
The error you got may have had to do with the heredoc echo echo <<<EOT
PHP does not want to see anything else on the line after ending EOT; and it must start in column one of the line. Depend on your PHP rev.
PHP Heredoc
The code below is untested. I put a lot of effort to make your code more elegant.
I added a few things from my standard PHP/HTML page template.
The height attribute of <td> is not supported in HTML5. Use CSS instead.
td{height:25px;text-align:center;}
I don't think this is needed: <div class="floatleft">
I added text-align:left to the CSS
<img> width and height do not have a px suffix.
When the are no PHP errors, the next thing to do is check your HTML an CSS with the W3C validators.
W3C HTML Validator
W3C CSS Validator
I also highly recommend these performance checkers:
GT Metrix
Google PageSpeed Insights
This one has every detail of were every millisecond of page load went.
enter link description here
You have an anchor in the last column and the the <td></td> looks blank. IKadded the word Edit.
I do not like GET links. I much prefer POST. This is how I do links in a table cell.
<td><form action="http://firestar/ProjectInsight/create_insight_package_live_link.php" method="post"><input type="hidden" name="entry" value="$file" /><button>Edit</button></form><td>
And the new updated code.
<?php
header('Content-Type: text/html; charset=utf-8');
header('Connection: Keep-Alive');
header('Keep-Alive: timeout=5, max=100');
header('Cache-Control: max-age=1800');
echo <<<EOT
<!DOCTYPE html><html lang="en">
<head>
<meta charset="utf-8">
<title>PI Project Switcher</title>
<style>
table width:700px;border: 1px solid black;>
td{height:25px;text-align:center;font 400 1em Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif; }
.large{font-size:1.2em;}
.small{font-size:.8em;background-color:#E0E0E0;}
</style>
</head>
<body>
<title>PI Project Switcher</title>
<table><tr class="small"><td style="width:660px; height:35px; text-align:left; valign:middle;">Package Name</td><td style="width:40px height:35px;">Live</td><td style="width:40px height35px;">Ready</td><td style="width:40px height35px;">Edit Mode</td></tr>
EOT;
$live_link = file_get_contents('./PIProjectSwitcher/live_link.php');
foreach(glob("./Insight_Packages/*.*") as $file){
if ($file == '.' || $file == '..' || $entry == "Blank-Package"){continue;}
$equal = 0;
if ($live_link = $file) {$equal = 1;}
echo <<< EOT
<tr valign="middle">
<td class="large">$file</td>
<td><img src="./images/$live[$equal]" width="25" height="25" id="$file" name="$file" />Edit</td>
<td style="height:25px;text-align:center;"><img src="./images/$ready[$equal]" class="floatcenter" width="25px" height="25" /></td>
<td style="height:25px;text-align:center;"><img src="./images/$editmode[$equal]" class="floatcenter" width="25" height="25" /></td></tr>
</table>
EOT;
}
?>
End of Update
Let's start here:
Replace this:
<?php
$live_link_file = 'PIProjectSwitcher/live_link.php';
$f = fopen($live_link_file, 'r');
if ($f) {
$live_link = fread($f, filesize($live_link_file));
fclose($f);
}
?>
with this:
$live_link = file_get_contents('./PIProjectSwitcher/live_link.php');
And clean up the output code.
foreach(glob("./Insight_Packages/*.*") as $file){
if $file == '.' || $file == '..' || $entry == "Blank-Package"){continue;}
$equal = 0;
if ($live_link = $file) {$equal = 1;}
echo <<< EOT"<tr valign="middle">
<div class="floatleft"><td height="25" style="font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif; font-size: large;">{$file}</div></td>
<td height="25" align="center">
<img src="images/$live$ready" class="floatcenter" width="25px" height="25px" id="$file" name="$file" /></td>
<td height="25" align="center"><img src="images/$live$ready" class="floatcenter" width="25px" height="25px" /></td>
<td height="25" align="center"> </td>
</tr>";
EOT;
}
Select the .png's based on $equal
Define these arrays before the loop
Where the array outputs [not equal value,equal value]
$live = array('greylight.png','greenlight.png');
$ready = array('greenlight.png','greylight.png');
$editmode = array('locked.png','locked.png');
Add this near the top of the loop
$equal = 0;
if ($live_link = $file) {$equal = 1;}
Then in the loop
echo <tr><td>$live[$equal]</td><td> $ready[$equal]</td></tr>$editmode[$equal]
I'm working on a project that is to take a standalone PHP application and move it to WordPress. I've done that and now within WordPress, I am working a particular registration sequence for soccer players to register themselves as players for a team. At a point in the sequence the user uploads an image of themselves. In the code, it is the file 'select-image.php' that is then attempting to retrieve 'upload-image.php' and edit-image.php' but returning error codes 301 an 302 respectively for each.
I've attached a screenshot showing the network activity when upload-image.php and edit-image.php are attempted to be retrieved. Neither resource has been moved permanently. I've also attached a screenhot showing the file is in fact where it is supposed to be on the server.
'select-image.php'
<?php
require_once $_SERVER ['DOCUMENT_ROOT'] . '/required-php-db-connect.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/session-library.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/ACS-library.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/org-library.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/constants-library.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/cart-library.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/division-library.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/team-library.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/user-library.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/form-library.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/image-library.php';
// request page post variables here, ensure that '/libraries/form-library.php' is required above
$return_page = "";
if(!empty($_POST["return_page"])){
$return_page = $_POST["return_page"];
}
// pre-header php functions (such as ACS activities)
$return_page = "";
if(!empty($_POST["return_page"])){
$return_page = $_POST["return_page"];
}
$image_mode = get_session_value('image_mode');
if ($image_mode == "") {
$image_mode = optional_form_item('image_mode');
}
if ($image_mode == 'cart_image_mode'){
$debug_mode = get_session_value('debug_mode');
$debug_string = "";
$transaction_id = get_session_value('transaction_id');
$user_cart = new Cart();
$user_cart->load_cart($transaction_id);
$cart_user_info = new cart_user_info();
$cart_user_info->load_cart_user_info_by_transaction_id($transaction_id);
$user_id = $cart_user_info->get_cart_user_info_user_id();
} else {
$user_id = optional_form_item('user_id');
$team_id = optional_form_item('team_id');
set_session_value('edit_team_id',$team_id);
}
set_session_value('image_edit_user_id', $user_id);
// load jquery libraries
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/jquery-link-library.php';
// load common css libraries
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/css-link-library.php';
$age_level = get_session_value('age_level');
if($age_level == 'youth') {
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/bootstrap-library.php';
}
//get default season
$this_season = new Season();
$season_text = $this_season->display_current_soccer_year();
$error_message = get_session_value('error_message');
set_session_value('error_message', null);
// load page specific css libraries
//require once $_SERVER['document_root'].'/libraries/roster.css';
?>
<!-- all local style references go here. USE SPARINGLY! -->
<style type=text/css>
.inactive_step {
font-weight: normal;
border:thin #000000 solid;
display:inline-block;
}
.active_step {
font-weight: bold;
border: thin #FF0000 solid;
display:inline-block;
}
</style>
</head>
<body id='body'>
<div class="wrapper">
<!-- location of libraries that display data to the page, in the order that the data is displayed -->
<?php if($age_level == 'youth') { require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/new-menu-bar.php'; } else { require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/menu-bar.php'; } ?>
<?php require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/admin-header.php'; ?>
<div class="main_body">
<!-- place all content here -->
<?php
if($age_level == 'youth'){
echo '<div class="jumbotron" style="margin: auto;">';
}
//$image_path = determine_user_image_path($user_id) . "/". get_user_image_file_name($user_id);
$image_path = get_image_database_path_and_name($user_id);
//1:
//place ACS and id user info here
//$user_id = get_cart_session_id();
if (empty($error_text)){
//create page output here
} else {
$display_data = $error_text;
}
?>
<font style="font-size: 18pt; color: red; align: center;"><?php echo $error_message; ?></font>
<table align="center" cellspacing="0" cellpadding ="0" width="1000" style="border: solid black 2px; align-self: center; margin: auto;">
<?php
if ($image_mode == 'cart_image_mode' && $age_level != 'youth'){
echo '<tr style = "border-bottom: solid black 2px;">';
echo '<td colspan="2" width="1000" align="center">';
display_progress(3);
echo "</td> </tr>";
} else if($image_mode == 'cart_image_mode' && $age_level == 'youth') {
echo '<tr>
<td colspan=2>
<h1>Youth Player Registration</h1>
<h3>' . trim($season_text) . '</h3>
</td>
</tr>
<tr>
<td colspan="2" width="970" align="center">';
display_new_progress(5);
echo "</td> </tr>";
}
?>
<tr>
<td valign="top" colspan =2 align= 'center' style = "font-size: 18px;"> <!-- BOTH sides of box -->
<table cellspacing=0 cellpadding=3 border=0 width=1000 align='center' >
<tr>
<td colspan="2" align="left" style="padding-left: 10px;">
<br />
Click <strong>Browse</strong> to upload your picture or take a picture with your cell phone.
<br />
<br />
Please select a picture that clearly shows your face.
<br /><br />
A small camera picture works MUCH better than a facebook picture. You will have a chance to rotate and crop the picture to select just your face. If you cannot get a picture to load correctly, it is probably too large in size or dimension. Use a smaller picture.
<br /> <br />
You MUST click on the box, shown below on the left (Current Picture), at least once for your picture to show up correctly.<br /><br /> Once you find the file or select your picture, click <strong>Upload Picture</strong>.
<br />
<br />
</td>
</tr>
<tr >
<td align="center">
<font style="font-size:16px;">Current Picture</font>
<br>
<img src="<?php echo $image_path; ?>" height="200px;" width="200px;"><br />
<br />
</td>
<td align="center" >
<br />
<form enctype="multipart/form-data" method="post" id="select_image_form" action="/images/upload-image.php" style='font-size: 18px;'>
<div class="row">
<label for="fileToUpload" style='font-size: 18px;'></label>
<button style='height: 70px; width: 250px; font-size:18px;' onclick="document.getElementById('fileToUpload').click();">Click here to select a file or take a pic with your phone</button>
<div style='height: 0px;width: 0px; overflow:hidden;'>
<input type="file" accept="capture=camera" name="fileToUpload" id="fileToUpload" style='font-size: 18px;' onchange="var x = document.getElementById('fileToUpload').value;document.getElementById('file_display').value = x; "/>
</div><br />
File to upload: <input type=text id="file_display" ></input>
<input type="hidden" name = "user_id" value = "<?php echo $user_id ?>">
<input type="hidden" name = "return_page" value = "<?php echo $return_page ?>">
</div>
<div class="row">
<br />
<input type="submit" style='font-size: 18px;' value="Upload This Picture" />
</div>
</form>
<br>
<form action="/images/edit-image-action.php" method="post">
<input type = 'hidden' name = 'image_action' value = 'save_old' />
<input type='hidden' name='old_path' value = '<?php echo $image_path; ?>' />
<input type="submit" style='font-size: 18px;' value="Keep the Current Pic and Skip This Step">
</form>
</td>
</tr>
</table><br />
<!-- Add in javascript based 'press button once' feature -->
</td>
</tr>
</table>
</div> <!-- end of main content area -->
<?php require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/user-footer.php'; ?>
</div> <!-- end of wrapper -->
</body>
</html>
<script type="text/javascript">
$( "#select_image_form" ).validate({
rules: {
fileToUpload: {
required: true,
accept: "image/*"
}
},
messages: {
fileToUpload:{
required: "You must select a picture to continue",
accept: "You must select an Image File."
}
}
});
</script>
'upload-image.php'
<?php
require_once $_SERVER ['DOCUMENT_ROOT'] . '/required-php-db-connect.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/session-library.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/ACS-library.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/user-library.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/cart-library.php';
require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/image-library.php';
$debug_mode = get_session_value('debug_mode');
$debug_string = "";
$debug_string .= "<br/> Debug Mode: $debug_mode";
$redirect_url = "/images/edit-image.php";
//set memory limit to accomodate uploading of 8MB images -TF
ini_set("memory_limit", "512M");
//$user_id = get_cart_session_id();
$image_mode = get_session_value('image_mode');
if ($image_mode == 'admin_image_mode'){
$user_id = get_session_value('image_edit_user_id');
}else {
$transaction_id = get_session_value('transaction_id');
$cart_user_info = new Cart_user_info();
$cart_user_info->load_cart_user_info_by_transaction_id($transaction_id);
$user_id = $cart_user_info->get_cart_user_info_user_id();
}
if ($_FILES['fileToUpload']['error'] > 0) {
$debug_string .= UploadException($_FILES['fileToUpload']['error']);
} else {
// array of valid extensions
$validExtensions = array('.jpg', '.jpeg', '.gif', '.png');
// get extension of the uploaded file
$fileExtension = strtolower(strrchr($_FILES['fileToUpload']['name'], "."));
// check if file Extension is on the list of allowed ones
if (in_array($fileExtension, $validExtensions)) {
// we are renaming the file so we can upload files with the same name
// we simply put current timestamp in front of the file name
$newName = time() . '_' . $_FILES['fileToUpload']['name'];
$destination = '/images/temp/' . $newName;
if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'], 'c:/inetpub/wwwroot'.$destination)) {
$manipulator = new ImageManipulator();
$manipulator->setImageFile($_SERVER[ 'DOCUMENT_ROOT' ] . $destination);
$manipulator->rotate('360');
// rotate 360 degrees
//$newImage = rotateImage($image, 360);
//$manipulator->setImageResource($newImage);
$manipulator->save($_SERVER[ 'DOCUMENT_ROOT' ] . $destination);
//redirect_post($redirect_url, 'destination', $destination);
set_session_value("destination",$destination);
//header('Location: ' . $redirect_url);
}
} else {
$debug_string .= " <br/>You must upload an image...<br/> If the file you attempted to upload was an image, it may not be compatible with this system. Please try again with another file.";
}
}
?>
<html>
<head>
<title>save a picture</title>
<!-- all stylesheets go here -->
<link rel="stylesheet" href="/CSS/login.css" type="text/css" />
<link rel="stylesheet" href="/CSS/menu.css" type="text/css" />
<link rel="stylesheet" href="/CSS/common.css" type="text/css" />
<link rel="stylesheet" href="/images/demos.css" type="text/css" />
<link rel="stylesheet" href="/images/jquery.Jcrop.css" type="text/css" />
</head>
<body style="text-align:center;">
<div class="wrapper">
<!-- location of libraries that display data to the page, in the order that the data is displayed -->
<?php require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/logo-header.php'; ?>
<?php require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/menu-bar.php'; ?>
<?php require_once $_SERVER ['DOCUMENT_ROOT'] . '/libraries/admin-header.php'; ?>
<div class="main_body">
<!-- place all content here -->
<?php
$next_page = $redirect_url;
$debug_string .= "<br/> Next page: $next_page";
$debug_string .= "<br/> Debug Mode: $debug_mode";
echo $debug_string;
upload_image_button($user_id);
header("location: $next_page");
continue_or_debug($next_page, $debug_mode);
?>
</div>
</div>
</body>
</html>
If you need 'edit-image.php' I can post that.
I don't understand why the error is saying the resource 'upload-image.php' has been permenently moved when it is very clearly sitting in the directory it needs to be in?
What gives?
Thanks,
CM
Network activity screenshot
screenshot of resource on server
ok here is my issue, this code worked for me before but my server ended up updating php from 5.2 to 5.5 then it all messed up/
soon as i made it back 5.2 it worked again but now my checkout.php wont capture the values from managecart.php
any help would be appreciated.
below = managecart.php code
<?
session_start();
include("includes/db.php");
include("includes/phpscripts.php");
include('includes/settings.php');
if($_GET["action"] == "addcat")
{
$GETCATNAME = str_replace("'","''",$_REQUEST['CATNAME']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$query = "INSERT INTO SHOPCAT VALUES ('','$GETCATNAME','0')";
mysql_query($query);
}
if($_GET["action"] == "editcat")
{
$GETCATNAME2 = str_replace("'","''",$_REQUEST['CATNAME2']);
$GETSHOPCAT2 = str_replace("'","''",$_REQUEST['SHOPID2']);
$GETSOLDOUT2 = str_replace("'","''",$_REQUEST['SOLDOUT2']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$query = "UPDATE SHOPCAT SET CATNAME = '$GETCATNAME2', SOLDOUT = '$GETSOLDOUT2' WHERE SHOPID = '$GETSHOPCAT2'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
}
if($_GET["action"] == "saveproduct")
{
$SAVEPID = str_replace("'","''",$_REQUEST['PID']);
unset($imagename);
if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;
if(!isset($_FILES['image_file']))
$error["image_file"] = "An image was not found.";
$newphrase = $SAVEPID.".jpg";
$imagename = str_replace(" ", "-", $newphrase);
if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";
if(empty($error))
{
$newimage = $imagename;
if(basename($_FILES['image_file']['name']) == "")
{
}
else
{
$result = #move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
$source = $imagename;
$target = "products/$source";
$width = 200;
$height = 133;
$quality = 100;
$size = getimagesize($source);
//scale evenly
$ratio = $size[0] / $size[1];
if ($ratio >= 1){
$scale = $width / $size[0];
} else {
$scale = $height / $size[1];
}
// make sure its not smaller to begin with!
if ($width >= $size[0] && $height >= $size[1]){
$scale = 1;
}
$im_in = imagecreatefromjpeg ($source);
$im_out = imagecreatetruecolor($size[0] * $scale, $size[1] * $scale);
imagecopyresampled($im_out, $im_in, 0, 0, 0, 0, $size[0] * $scale, $size[1] * $scale, $size[0], $size[1]);
imagejpeg($im_out, $target, $quality);
imagedestroy($im_out);
imagedestroy($im_in);
$result = #move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
$source = $imagename;
$target = "products/large/$source";
$width = 600;
$height = 400;
$quality = 100;
$size = getimagesize($source);
//scale evenly
$ratio = $size[0] / $size[1];
if ($ratio >= 1){
$scale = $width / $size[0];
} else {
$scale = $height / $size[1];
}
// make sure its not smaller to begin with!
if ($width >= $size[0] && $height >= $size[1]){
$scale = 1;
}
$im_in = imagecreatefromjpeg ($source);
$im_out = imagecreatetruecolor($size[0] * $scale, $size[1] * $scale);
imagecopyresampled($im_out, $im_in, 0, 0, 0, 0, $size[0] * $scale, $size[1] * $scale, $size[0], $size[1]);
imagejpeg($im_out, $target, $quality);
imagedestroy($im_out);
imagedestroy($im_in);
}
}
$DelFile = $imagename;
if(basename($_FILES['image_file']['name']) == "")
echo "";
else
unlink($DelFile);
$SAVEPNAME = str_replace("'","''",$_REQUEST['PNAME']);
$SAVEPTEXT = str_replace("'","''",$_REQUEST['PTEXT']);
$SAVEPPRICE = str_replace("'","''",$_REQUEST['PPRICE']);
$SAVEPID = str_replace("'","''",$_REQUEST['PID']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
if(basename($_FILES['image_file']['name']) == "")
{
$query = "UPDATE SHOPPRODUCTS SET PNAME = '$SAVEPNAME', PTEXT = '$SAVEPTEXT', PPRICE = '$SAVEPPRICE' WHERE PID = '$SAVEPID'";
}
else
{
$query = "UPDATE SHOPPRODUCTS SET PNAME = '$SAVEPNAME', PTEXT = '$SAVEPTEXT', PPRICE = '$SAVEPPRICE', PIMAGE ='1' WHERE PID = '$SAVEPID'";
}
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
}
if($_GET["action"] == "addproduct")
{
$GETPNAME = str_replace("'","''",$_REQUEST['PNAME']);
$GETPTEXT = str_replace("'","''",$_REQUEST['PTEXT']);
$GETPPRICE = str_replace("'","''",$_REQUEST['PPRICE']);
$GETPCAT = str_replace("'","''",$_REQUEST['PCAT']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$query = "INSERT INTO SHOPPRODUCTS VALUES ('','$GETPNAME','$GETPTEXT','$GETPPRICE','$GETPCAT','0')";
mysql_query($query);
}
if($_GET["action"] == "editcat")
{
$GETCATNAME2 = str_replace("'","''",$_REQUEST['CATNAME2']);
$GETSHOPCAT2 = str_replace("'","''",$_REQUEST['SHOPID2']);
$GETSOLDOUT2 = str_replace("'","''",$_REQUEST['SOLDOUT2']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$query = "UPDATE SHOPCAT SET CATNAME = '$GETCATNAME2', SOLDOUT = '$GETSOLDOUT2' WHERE SHOPID = '$GETSHOPCAT2'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
}
?>
<?
if($_GET["action"] == "deleteshopcat")
{
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$TID = $_REQUEST['DID'] ;
$sql = "DELETE FROM SHOPCAT WHERE SHOPID = '$TID'";
mysql_query($sql);
//mysql_close();
}
?>
<?
if($_GET["action"] == "deleteproduct")
{
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$TID = $_REQUEST['DID'] ;
$sql = "DELETE FROM SHOPPRODUCTS WHERE PID = '$TID'";
mysql_query($sql);
//mysql_close();
}
?>
<!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><?echo$SHOWTITLE?></title>
<meta name="description" content="<?echo$SHOWDESC?>" />
<meta name="keywords" content="<?echo$SHOWKEYS?>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/menu.css" rel="stylesheet" type="text/css" />
<SCRIPT SRC="language-en.js"></SCRIPT>
<SCRIPT SRC="nopcart.js"></SCRIPT>
<script>
function Edit(id)
{
window.open("editor/examples/editor1.php?ID="+id,"test","toolbar=no,location=no,status=no,resizable=yes,scrollbars=auto,width=700,height=600,top=50,left=50");
}
</script>
<script language="JavaScript">
<!--
function Form1()
{
if(document.form2.NAME.value=="")
{
alert("Please Enter Page Name");
return false;
}
}
function Form2()
{
if(document.form3.SUBONENAME.value=="")
{
alert("Please Enter Sub Page Name");
return false;
}
}
function Form3()
{
if(document.form4.SUBTWONAME.value=="")
{
alert("Please Enter Sub Page Name");
return false;
}
}
//-->
</script>
<script>
function DeletePage(id)
{
if(confirm("Are you really really sure you want to delete this page?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?action=delete&DID="+id
}
}
}
</script>
<script>
function DeleteProd(id)
{
if(confirm("Are you really really sure you want to delete this product?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?ID=49&action=deleteproduct&DID="+id
}
}
}
</script>
<script>
function DeleteShopCat(id)
{
if(confirm("Are you really really sure you want to delete this catagoy?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?ID=49&action=deleteshopcat&DID="+id
}
}
}
</script>
<script>
function showit(it) {
document.getElementById(it).style.display = "block";
}
function hideit(it) {
document.getElementById(it).style.display = "none";
}
function hideall() {
for (var i=1; i<=2; i++) {
hideit("x" + i);
}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
<style type="text/css">
<!--
body {
background-image: url(back.jpg);
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<link href="css/florida.css" rel="stylesheet" type="text/css" />
</head>
<body onload="MM_preloadImages('images/button1_2.jpg','images/button2_2.jpg')">
<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top" background="mainback.jpg"><table width="944" height="717" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="109"><div align="right"><img src="images/facebook.jpg" width="310" height="50" border="0" /><br />
<img src="images/button1_1.jpg" name="Image4" border="0" id="Image4" /><img src="images/button2.jpg" width="32" height="59" /><img src="images/button2_1.jpg" name="Image6" width="129" height="59" border="0" id="Image6" /></div></td>
</tr>
<tr>
<td height="159">
</td>
</tr>
<tr>
<td valign="top"><table width="941" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"> </td>
<td valign="top" class="TextD"><br /> </td>
</tr>
<tr>
<td width="156" valign="top"><table width="155" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="images/menuback.jpg"><br />
<table width="156" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="28"> </td>
<td width="128" valign="top"><? include("menu.php");?>
<br />
<br /></td>
</tr>
</table>
<div align="left"><img src="images/menubottom.jpg" width="149" height="69" /><br />
</tr>
</table>
<?php
if ($_SESSION['florida']=='fields321')
{
?>
<div align="left">
<span class="link2"> • Edit Menu</span><br />
<span class="link2"> • Logout</span><br />
<span class="link2"> • Page Settings</span><br />
<span class="link2"> • Sort Menu</span><br />
<span class="link2"> • Members</span><br />
<span class="link2"> • Orders</span><br />
<span class="link2"> • Edit Gallery</span><br />
</div>
<?
}
?>
<span class="link2"> • Shop The Farm</span><br />
</td>
<td width="779" valign="top"><span class="TextB"><strong>SHOPPING CART</strong></span><br />
<br />
<span class="TextB">Members are responsible for all paypal fees. The fee will be listed on your invoice as shipping.</span> <br />
<br />
<FORM ACTION="checkout.php" NAME="form" METHOD="GET" onSubmit="return ValidateCart(this)">
<div align="left">
<script>
ManageCart();
</script>
<input type=IMAGE src="images/placeorder.jpg" alt="Place Order" border=0 /> <img src="images/returntocart.jpg" border="0"/>
</div>
</FORM><br /></td>
</tr>
</table></td>
</tr>
</table>
<br /></td>
</tr>
<tr>
<td align="center"> </td>
</tr>
</table>
</body>
</html>
below = checkout.php code
<?
session_start();
?>
<?
$strMessageBody .= "$QUANTITY_1 - \$$PRICE_1 - $NAME_1 <br>";
if( $NAME_2 ) {$strMessageBody .= "$QUANTITY_2 - \$$PRICE_2 - $NAME_2 <br>";}
if( $NAME_3 ) {$strMessageBody .= "$QUANTITY_3 - \$$PRICE_3 - $NAME_3 <br>";}
if( $NAME_4 ) {$strMessageBody .= "$QUANTITY_4 - \$$PRICE_4 - $NAME_4 <br>";}
if( $NAME_5 ) {$strMessageBody .= "$QUANTITY_5 - \$$PRICE_5 - $NAME_5 <br>";}
if( $NAME_6 ) {$strMessageBody .= "$QUANTITY_6 - \$$PRICE_6 - $NAME_6 <br>";}
if( $NAME_7 ) {$strMessageBody .= "$QUANTITY_7 - \$$PRICE_7 - $NAME_7 <br>";}
if( $NAME_8 ) {$strMessageBody .= "$QUANTITY_8 - \$$PRICE_8 - $NAME_8 <br>";}
if( $NAME_9 ) {$strMessageBody .= "$QUANTITY_9 - \$$PRICE_9 - $NAME_9 <br>";}
if( $NAME_10 ){$strMessageBody .= "$QUANTITY_10 - \$$PRICE_10 - $NAME_10 <br>";}
if( $NAME_11 ){$strMessageBody .= "$QUANTITY_11 - \$$PRICE_11 - $NAME_11 <br>";}
if( $NAME_12 ){$strMessageBody .= "$QUANTITY_12 - \$$PRICE_12 - $NAME_12 <br>";}
if( $NAME_13 ){$strMessageBody .= "$QUANTITY_13 - \$$PRICE_13 - $NAME_13 <br>";}
if( $NAME_14 ){$strMessageBody .= "$QUANTITY_14 - \$$PRICE_14 - $NAME_14 <br>";}
if( $NAME_15 ){$strMessageBody .= "$QUANTITY_15 - \$$PRICE_15 - $NAME_15 <br>";}
if( $NAME_16 ){$strMessageBody .= "$QUANTITY_16 - \$$PRICE_16 - $NAME_16 <br>";}
if( $NAME_17 ){$strMessageBody .= "$QUANTITY_17 - \$$PRICE_17 - $NAME_17 <br>";}
if( $NAME_18 ){$strMessageBody .= "$QUANTITY_18 - \$$PRICE_18 - $NAME_18 <br>";}
if( $NAME_19 ){$strMessageBody .= "$QUANTITY_19 - \$$PRICE_19 - $NAME_19 <br>";}
if( $NAME_20 ){$strMessageBody .= "$QUANTITY_20 - \$$PRICE_20 - $NAME_20 <br>";}
if( $NAME_21 ){$strMessageBody .= "$QUANTITY_21 - \$$PRICE_21 - $NAME_21 <br>";}
if( $NAME_22 ){$strMessageBody .= "$QUANTITY_22 - \$$PRICE_22 - $NAME_22 <br>";}
if( $NAME_23 ){$strMessageBody .= "$QUANTITY_23 - \$$PRICE_23 - $NAME_23 <br>";}
if( $NAME_24 ){$strMessageBody .= "$QUANTITY_24 - \$$PRICE_24 - $NAME_24 <br>";}
if( $NAME_25 ){$strMessageBody .= "$QUANTITY_25 - \$$PRICE_25 - $NAME_25 <br>";}
if( $NAME_26 ){$strMessageBody .= "$QUANTITY_26 - \$$PRICE_26 - $NAME_26 <br>";}
if( $NAME_27 ){$strMessageBody .= "$QUANTITY_27 - \$$PRICE_27 - $NAME_27 <br>";}
if( $NAME_28 ){$strMessageBody .= "$QUANTITY_28 - \$$PRICE_28 - $NAME_28 <br>";}
$wcart = $strMessageBody;
$strMessageBody2 .= "$TOTAL";
$wcart = $strMessageBody;
$wtotal = $strMessageBody2;
?>
<!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>Florida Fields To Forks</title>
<meta name="description" content="<?echo$SHOWDESC?>" />
<meta name="keywords" content="<?echo$SHOWKEYS?>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/menu.css" rel="stylesheet" type="text/css" />
<SCRIPT SRC="language-en.js"></SCRIPT>
<SCRIPT SRC="nopcart.js"></SCRIPT>
<script>
function Edit(id)
{
window.open("editor/examples/editor1.php?ID="+id,"test","toolbar=no,location=no,status=no,resizable=yes,scrollbars=auto,width=700,height=600,top=50,left=50");
}
</script>
<script language="JavaScript">
<!--
function Form1()
{
if(document.form2.NAME.value=="")
{
alert("Please Enter Page Name");
return false;
}
}
function Form2()
{
if(document.form3.SUBONENAME.value=="")
{
alert("Please Enter Sub Page Name");
return false;
}
}
function Form3()
{
if(document.form4.SUBTWONAME.value=="")
{
alert("Please Enter Sub Page Name");
return false;
}
}
function checkoutone()
{
if(document.forma.PICKUP1.value=="")
{
alert("Please Enter Pick-up Date");
return false;
}
}
function checkouttwo()
{
if(document.formb.PICKUP1.value=="")
{
alert("Please Enter Pick-up Date");
return false;
}
}
//-->
</script>
<script>
function DeletePage(id)
{
if(confirm("Are you really really sure you want to delete this page?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?action=delete&DID="+id
}
}
}
</script>
<script>
function DeleteProd(id)
{
if(confirm("Are you really really sure you want to delete this product?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?ID=49&action=deleteproduct&DID="+id
}
}
}
</script>
<script>
function DeleteShopCat(id)
{
if(confirm("Are you really really sure you want to delete this catagoy?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?ID=49&action=deleteshopcat&DID="+id
}
}
}
</script>
<script>
function showit(it) {
document.getElementById(it).style.display = "block";
}
function hideit(it) {
document.getElementById(it).style.display = "none";
}
function hideall() {
for (var i=1; i<=2; i++) {
hideit("x" + i);
}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
</script>
<style type="text/css">
<!--
body {
background-image: url(back.jpg);
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<link href="css/florida.css" rel="stylesheet" type="text/css" />
</head>
<?
$GETMYTOTAL = $SHOWMEQ;
?>
<body onload="MM_preloadImages('images/button1_2.jpg','images/button2_2.jpg')">
<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top" background="mainback.jpg"><table width="944" height="717" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="109"><div align="right"><img src="images/facebook.jpg" width="310" height="50" border="0" /><br />
<img src="images/button1_1.jpg" name="Image4" border="0" id="Image4" /><img src="images/button2.jpg" width="32" height="59" /><img src="images/button2_1.jpg" name="Image6" width="129" height="59" border="0" id="Image6" /></div></td>
</tr>
<tr>
<td height="159">
</td>
</tr>
<tr>
<td valign="top"><table width="941" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"> </td>
<td valign="top" class="TextD"><br /> </td>
</tr>
<tr>
<td width="156" valign="top"><table width="155" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="images/menuback.jpg"><br />
<table width="156" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="28"> </td>
<td width="128" valign="top"><? include("menu.php");?>
<br />
<br /></td>
</tr>
</table>
<div align="left"><img src="images/menubottom.jpg" width="149" height="69" /><br />
</tr>
</table>
<?php
if ($_SESSION['florida']=='fields321')
{
?>
<span class="link2"> • Edit Menu</span><br />
<span class="link2"> • Logout</span><br />
<span class="link2"> • Page Settings</span><br />
<span class="link2"> • Sort Menu</span><br />
<span class="link2"> • Members</span><br />
<?
}
?>
<span class="link2"> • View Cart</span><br />
<span class="link2"> • Shop The Farm</span><br />
</td>
<td width="779" valign="top"><span class="TextC">Please review your order and select payment method below.<br>
Please be sure to submit a Pick Up Date thank you. <br />
</span><br />
<br />
View available dates<br />
<br />
<span class="TextB"><?echo$wcart?></span><br />
<table width="486" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><form id="forma" name="forma" method="post" action="checkout_check.php" onSubmit="return checkoutone();">
<span class="TextA">Pick-up date:</span>
<input name="PICKUP1" type="text" class="TextA" id="PICKUP1" size="20" />
<span class="TextA">Comments:</span>
<input name="COMMENTS1" type="text" class="TextA" id="COMMENTS1" size="20" />
<input type="hidden" name="memberid" value="<?echo$_SESSION['memberid']?>">
<input type="hidden" name="cart" value="<?echo$wcart?>">
<input type="hidden" name="amount" value="<?echo$SHOWMEQ?>">
<label>
<input name="button" type="submit" class="TextB" id="button" value="Pay by Check" />
</label>
</form></td>
<td><form id="formb" name="formb" method="post" action="checkout_paypal.php" onSubmit="return checkouttwo();">
<span class="TextA">Pick-up date:</span>
<input name="PICKUP1" type="text" class="TextA" id="PICKUP1" size="20" />
<span class="TextA">Comments:</span>
<input name="COMMENTS1" type="text" class="TextA" id="COMMENTS1" size="20" />
<input type="hidden" name="memberid" value="<?echo$_SESSION['memberid']?>">
<input type="hidden" name="cart" value="<?echo$wcart?>">
<input type="hidden" name="amount" value="<?echo$SHOWMEQ?>">
If you use globals, then now as they don't exist, you need to carry those variables around in different way, as function's parameters or $_SESSION variables
I just can't get this to work, basically Im displaying the files on a ftp server, which works fine, but some of the folder names have german characters like ä ö ü or french characters. I placed the line below into the php code to see if it helps but it only gets rid of the french characters, however the german characters still have the � icon instead of the actual character...
header('Content-Type: text/html; charset=utf-8');
I would appreciate any help. Below is the whole file:
import.php
<html>
<head>
<title>Import</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="css/import.css"/>
<style type="text/css">
.folder_hilighted table tr td div.name_tag_name{
background: #75B323;
color: #ffffff;
border-radius: 20px;
text-shadow: 0px -1px 0px #5D855A;
}
</style>
</head>
<body><br>
<table width="100%" cellspacing="0" cellpadding="0"><tr><td>
<ul class="folders">
<?php
ini_set("max_execution_time",100000);
$folder = $_GET['folder'];
// set up basic connection
$ftp_server = "xxx.xxx.xx.xx";
$ftp_user_name = "admin";
$ftp_user_pass = "password";
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// get the file list for /
if($folder==""){
$buff = ftp_nlist($conn_id, '/array1/MediaBox/iTunes/');
}
else{
$buff = ftp_nlist($conn_id, '/array1/MediaBox/iTunes/'.$folder.'/');
}
// close the connection
ftp_close($conn_id);
// output the buffer
for($i=0;$i<=sizeof($buff)-1;$i++){
if(is_dir('ftp://'.$ftp_user_name.':'.$ftp_user_pass.'#'.$ftp_server.$buff[$i]) && $buff[$i]!="/array1/MediaBox/iTunes/Mobile Applications" && $buff[$i]!="/array1/MediaBox/iTunes/Automatically Add to iTunes.localized" && $buff[$i]!="/array1/MediaBox/iTunes/Books" && $buff[$i]!="/array1/MediaBox/iTunes/Tones"){
if($folder==""){
$folder_name = str_replace(array("/array1/MediaBox/iTunes/"), array(""), $buff[$i]);
$folder_name = mb_convert_encoding($folder_name, 'UTF-8', mb_detect_encoding($folder_name));
$folder_name = htmlspecialchars($folder_name, ENT_QUOTES, 'UTF-8');
}
else{
$folder_name = str_replace(array("/array1/MediaBox/iTunes/".$folder."/"), array(""), $buff[$i]);
$folder_name = mb_convert_encoding($folder_name, 'UTF-8', mb_detect_encoding($folder_name));
$folder_name = htmlspecialchars($folder_name, ENT_QUOTES, 'UTF-8');
$last_folder = str_replace(array("/array1/MediaBox/iTunes/"), array(""), $buff[$i]);
$last_folders = explode("/", $last_folder);
for($k=0;$k<=count($last_folders);$k++){
if($k==count($last_folders)){
$prev_folder = $last_folders[$k-3];
}
}
}
?>
<li align="center" title="<?php echo $folder_name ?>" id="<?php echo md5($folder_name); ?>" onClick="hilight_folder('<?php echo md5($folder_name); ?>');" ondblclick="change_folder('<?php echo $folder_name; ?>')" style="cursor: pointer; height: 90px;">
<table cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<img height="75" style="padding-left: 5px; padding-right: 5px; padding-top: 5px;" src="img/folder.png">
<div class="prev_folder" style="display: none;"><?php echo $prev_folder ?></div>
</td>
</tr>
<tr>
<td align="center" class="name_tag">
<div class="name_tag_name" style="margin-top: 2px; width: auto;">
<?php
$short_folder = substr($folder_name, 0, 12);
if($folder_name == $short_folder){
}
else{
$short_folder = $short_folder."...";
}
echo $short_folder;
?>
</td>
</div>
</tr>
</table>
</li>
<?php
}
else if($buff[$i]!="/array1/MediaBox/iTunes/Mobile Applications" && $buff[$i]!="/array1/MediaBox/iTunes/Automatically Add to iTunes.localized" && $buff[$i]!="/array1/MediaBox/iTunes/Books" && $buff[$i]!="/array1/MediaBox/iTunes/Tones" && $buff[$i]!="/array1/MediaBox/iTunes/" && $buff[$i]!="/array1/MediaBox/iTunes/Icon"){
if($folder==""){
$folder_name = str_replace(array("/array1/MediaBox/iTunes/"), array(""), $buff[$i]);
}
else{
$folder_name = str_replace(array("/array1/MediaBox/iTunes/".$folder."/"), array(""), $buff[$i]);
$last_folder = str_replace(array("/array1/MediaBox/iTunes/"), array(""), $buff[$i]);
$last_folders = explode("/", $last_folder);
for($k=0;$k<=count($last_folders);$k++){
if($k==count($last_folders)){
$prev_folder = $last_folders[$k-3];
}
}
}
?>
<li align="center" title="<?php echo $folder_name ?>" id="<?php echo md5($folder_name); ?>" onClick="hilight_folder('<?php echo md5($folder_name); ?>');" ondblclick="change_folder('<?php echo str_replace(array("/array1/MediaBox/iTunes/"), array(""), $buff[$i]); ?>')" style="cursor: pointer; height: 90px;">
<table cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<img height="75" style="padding-left: 5px; padding-right: 5px; padding-top: 5px;" src="img/music_file.png">
<div class="prev_folder" style="display: none;"><?php echo $prev_folder ?></div>
</td>
</tr>
<tr>
<td align="center" class="name_tag">
<div class="name_tag_name" style="margin-top: 2px; width: auto;">
<?php
$short_folder = substr($folder_name, 0, 12);
if($folder_name == $short_folder){
}
else{
$short_folder = $short_folder."...";
}
echo $short_folder;
?>
</td>
</div>
</tr>
</table>
</li>
<?php
}
}
ftp_close($conn_id);
?>
</ul>
</td></tr>
<tr><td>
<div style="height: 60px;"> </div>
</td></tr></table>
</body>
</html>
If it's possible (if it is supported on FTP server) try to call:
ftp_raw($conn_id, "OPTS UTF8 ON");
This command enable UTF-8 encoding for directory listing (ftp_nlist).
Okay, I've worked out a work around which may be useful for other people to know:
str_replace(array('%82','%94','+'),array('é','ö',' '),urlencode($folder_name));
It's not the best way, but it works for me, if you url encode a string it changes the awkward characters into e.g. %82... You can then replace these with the HTML codes.
This is a page where users can edit their uploaded images. There is a checkbox near each image. I want to delete the selected images after user clicks the "delete selected images" button (each checkbox contains the image name as value). How can I do that?
<?php
session_start();
//////////////if user already logged in go to login.php/////////
if (isset($_SESSION['email'] )&& isset($_SESSION['password'] ))
{
} else{header( "Location: login.php" ); }
include('includes/config.php');
if (isset($_POST['esubmit']) ){
$checkbox=$_POST['delete'];
echo $checkbox;
}//main one
if (isset($_POST['esubmit']) ){
} else { $clickeditid=$_GET["id"];
$_SESSION['eid']= $clickeditid ;
}
?>
<!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>Untitled Document</title>
<link href="css/css.css" rel="stylesheet" type="text/css" />
<style rel="stylesheet" type="text/css">
input {
border-style: solid;
border-color: #000000;
border-width: 1px;
background-color: #ffffff;
}
</style>
<script src="js/css_browser_selector.js" type="text/javascript"></script>
</head>
<body>
<?php
include('includes/topmenu.php');//top menu
echo '<br />';
include('includes/usermenu.php');///bcoz of this menu error occurs
////////////////////
include('includes/edit_img_menu.php');
?>
<form id="form1" name="form1" method="post" action="editimg.php?id=<?php echo $_SESSION['eid'];?>">
<table align="center" width="70%" cellspacing="0">
<tr>
<td colspan="3" align="center" bgcolor="#FFFFFF"></td>
</tr>
<tr>
<td colspan="3" align="center" bgcolor="#FFFFFF"><?php
$imgcheck=mysql_query("
SELECT *
FROM `images`
WHERE `deal_id` =$_SESSION[eid]
LIMIT 0 , 30
");
$numimgcheck=mysql_num_rows($imgcheck);
if($numimgcheck==0){echo '<span style=color:#ff0000; >No pictures uploaded</span>';}
while ($rowimg2= mysql_fetch_array($imgcheck)){
$imgname=$rowimg2['name'];
{
echo ' <a href="users/'.$_SESSION['userid'].'/images/'.$imgname.'" rel="lightbox[slide]" caption=".">';
}
{ echo '<img src="users/'.$_SESSION['userid'].'/images/thumbs/'.$imgname.'" border="0" />';}
{ echo '</a><input type="checkbox" name="delete" id="delete" value="'.$imgname.'">
';}
}
?></td>
</tr>
<tr>
<td colspan="3" align="center" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td colspan="3" align="center" bgcolor="#95F8FD"><input name="esubmit" type="submit" class="red" id="esubmit" value="Delete selected images" /></td>
</tr>
<tr>
<td width="89"> </td>
<td colspan="2"> </td>
</tr>
</table>
</form>
</body>
</html>
You have to create a form to submit the data of the checked checkboxes and treate the submited result with the php code : if you want to put the php code on the same page, you can check if there is any data in the POST vars and create a SQL Query to delete the corresponding pictures.
You can find a very well documented tutorial here : http://sharemyphp.wordpress.com/2009/12/21/ajax-jquery-php-multiple-delete-item-with-check-box/
Regards,
Max
I use the below code to delete images in my admin panel. I saved the file as deletephoto.php. Note that this script works without login. You need to make some changes to fit your use case
<form method="post" action="deletepho.php">
<center>
<input type="submit" value="Delete" name="Delete">
</center>
<?php
\\lets assign the folder name in $title
\\You can assign any name
$title= "test";
\*$directory corresponds to whole path. Edit to your preference. (i assume u store your
images in directory named "images") */
$directory = "$title/images";
\\The array specifies the format of the files
$allowed_types=array('jpg','jpeg','gif','png');
$file_parts=array();
$ext='';
$title='';
$i=0;
$dir_handle = #opendir($directory) or die("There is an error with your image directory!");
while ($file = readdir($dir_handle))
{
if($file=='.' || $file == '..') continue;
$file_parts = explode('.',$file);
$ext = strtolower(array_pop($file_parts));
$title = implode('.',$file_parts);
$title = htmlspecialchars($title);
$nomargin='';
if(in_array($ext,$allowed_types))
{
if(($i+1)%4==0)
$nomargin='nomargin';
echo'
<div id="picture">
<img src="'.$directory.'/'.$file.'" width="150" height="150"><br>
Select <input type="checkbox" value="'.$directory.'/'.$file.'" name="imgfile[]">
\* I specified input name as an array . So that we can store in an array and delete it.*/
</div>';
}
$i++;
}
closedir($dir_handle);
\\Now we have the list of images within form elements
?>
</form>
Now here is the actual code to delete the photos. I saved it as deletepho.php.
$file = $_REQUEST['imgfile'];
$num_files=count($file);
for($i=0;$i<$num_files;$i++)
{
unlink ("$file[$i]");
}
echo "Images successfully deleted.Go <a href='deletephoto.php'>back</a>";