473,915 Members | 3,885 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

image validation

5 New Member
hi, friend. i have a problem in image validation plz check it.
i have to include a image validation in foam 1. but i sending a details through form2.
But when i include a image validation in foam1, then i can not change my image on
calling a function onchange="retur n valid1"
<my source code is here>
<?
session_start() ;
ob_start();
set_time_limit( 0);
include("includ es/vars.inc.php");
include("includ es/function.inc.ph p");
db_connect();
if(isset($_REQU EST['del']) && $_REQUEST['del']==1)
{
$path=$_REQUEST['img'];
$path1=$_REQUES T['img1'];
@unlink($path);
@unlink($path1) ;
?>
<script type="text/javascript" language="JavaS cript">
alert("File has been deleted");
</script>
<?
echo("file has been deleted");
header("locatio n:index.php");
}

if(isset($_FILE S['img']))
{
$num=substr(md5 (date("His")),0 ,10);
$img=$num." ".basename( $_FILES['img']['name']);
$_SESSION['img']=$img;
$upath="img_upl oad/".$img;
$x=@move_upload ed_file($_FILES['img']['tmp_name'], $upath);
$y=@filesize($u path)/1024;
$imgsize=getima gesize($upath);
//if($y<15)
{
//$err_msg="<stro ng>File must be more than 150 kb.</strong>";
//@unlink($upath) ;
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="styleshee t/main.css" rel="stylesheet " type="text/css">
<script language="javas cript">
function valid12()
{
var ext = document.upload _img.img.value;

if(document.upl oad_img.img.val ue !='' )
{
ext = ext.substring(e xt.length-3,ext.length);
ext = ext.toLowerCase ();
if(ext != 'jpg')
{
alert('You upload a '+ext+
' file please upload only jpg image.');
return false;
}
else
{
document.upload _img.submit();
}
}
return true;
}
</script>
<link rel="stylesheet " href="js/lightbox.css" type="text/css" media="screen" />
<script language=JavaSc ript src="colorpicke r/picker.js"></script>


<script language="javas cript">
function xmlhttpPost(str URL) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttp Request) {
self.xmlHttpReq = new XMLHttpRequest( );
}
// IE
else if (window.ActiveX Object) {
self.xmlHttpReq = new ActiveXObject(" Microsoft.XMLHT TP");
}
self.xmlHttpReq .open('POST', strURL, true);
self.xmlHttpReq .setRequestHead er('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq .onreadystatech ange = function() {
if (self.xmlHttpRe q.readyState == 4) {
updatepage(self .xmlHttpReq.res ponseText);
}
}
self.xmlHttpReq .send(getquerys tring());
}

function getquerystring( ) {
var xdir = document.proces s_img.xdir.valu e;
var ydir = document.proces s_img.ydir.valu e;
var msg = document.proces s_img.photomsg. value;
var path = document.proces s_img.path.valu e;
var col = document.proces s_img.input1.va lue;
var size = document.proces s_img.txtsize.v alue;
var font = document.proces s_img.font.valu e;

qstr = 'xdir=' + escape(xdir) + '&ydir=' + escape(ydir) + '&msg=' + escape(msg) + '&path=' + escape(path) + '&col=' + escape(col) + '&size=' + escape(size) + '&font=' + escape(font); // NOTE: no '?' before querystring
//alert(qstr);
return qstr;
}
function updatepage(str) {
document.getEle mentById("check availdiv").inne rHTML = str;
}

function createbanner()
{
if(isNaN(docume nt.process_img. xdir.value))
{
alert("Enter number only.");
document.proces s_img.xdir.focu s();
return false;
}
else if(isNaN(docume nt.process_img. ydir.value))
{
alert("Enter number only.");
document.proces s_img.ydir.focu s();
return false;
}
else
xmlhttpPost("te st.php");
}

</script>
<script language="javas cript">
function sess_del()
{
<?php

//unset($_SESSION['']);
?>
window.location .href="index.ph p";

}

function valid1()
{
if(document.pro cess_img.xdir.v alue=="")
{
alert("plz select the x size");
document.proces s_img.xdir.focu s();
return false;
}

if(document.pro cess_img.ydir.v alue=="")
{
alert("plz select the y size");
document.proces s_img.ydir.focu s();
return false;
}
}


function valid()
{
if(document.upl oad_img.img.val ue=="")
{
alert("Please browse image first.");
document.upload _img.img.focus( );
return false;
}


if(document.pro cess_img.photom sg.value=="")
{
alert("Enter some text.");
document.proces s_img.photomsg. focus();
return false;
}

if(document.pro cess_img.size.v alue==0)
{
alert("Select the size.");
document.proces s_img.size.focu s();
return false;
}

if(document.pro cess_img.materi al.value==0)
{
alert("Select the material.");
document.proces s_img.material. focus();
return false;
}
if(document.pro cess_img.quanti ty.value==0)
{
alert("Please select the qunatity of a product.");
document.proces s_img.quantity. focus();
return false;
}

}

function changeimg(cat)
{
switch(cat)
{

case 0:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font1" src="fonts/font1.JPG" width="200" height="50">';
break;
case 1:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font2" src="fonts/font2.JPG" width="200" height="50">';
break;
case 2:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font3" src="fonts/font3.JPG" width="200" height="50">';
break;
case 3:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font4" src="fonts/font4.JPG" width="200" height="50">';
break;
case 4:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font5" src="fonts/font5.JPG" width="200" height="50">';
break;
case 5:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font6" src="fonts/font6.JPG" width="200" height="50">';
break;
case 6:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font7" src="fonts/font7.JPG" width="200" height="50">';
break;
case 7:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font8" src="fonts/font8.JPG" width="200" height="50">';
break;
case 8:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font9" src="fonts/font9.JPG" width="200" height="50">';
break;
case 9:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font10" src="fonts/font10.JPG" width="200" height="50">';
break;
case 10:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font11" src="fonts/font11.JPG" width="200" height="50">';
break;
case 11:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font12" src="fonts/font12.JPG" width="200" height="50">';
break;
}

}
</script>
</head>
<body bgcolor="#FFFFF F" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0 " bottommargin="0 ">
<!-- ImageReady Slices (layout.psd) -->
<table id="Table_01" width="1000" cellpadding="0" cellspacing="0" align="center" class="fourbr">
<tr>
<td valign="top" height="165"><? include("header .php");?></td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFFF F"><table align="center" width="100%" border="0" height="310px">
<tr>
<td width="13px">&n bsp;</td>
<td valign="top"><t able border="0" width="100%">
<tr>
<td width="3%">
<img src="images/1.jpg" align="absmiddl e" border="0"></td>
<td width="19%" class="headblue ">Upload Photo</td>
<td width="78%">&nb sp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2"><sp an class="err">
<? if($err_msg) echo $err_msg;?>
</span></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">
<form name="upload_im g" method="post" action="" enctype="multip art/form-data">
<input type="file" name="img" onChange="retur n valid12();">
<?

if(isset($_FILE S['img']) && !$err_msg)
{ ?>
<input name="img" type="test" value="ghgh"/>
<? }


?>

</form></td>
</tr>
<tr>
<td><img src="images/2.jpg" align="absmiddl e" border="0"></td>
<td colspan="2" class="headoran ge">Choose Poster Specification</td>
</tr>
<form name="process_i mg" method="post" action="checkou t.php" onSubmit="retur n valid();">
<tr>
<td>&nbsp;</td>
<td></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top"><t able class="four" >
<tr>
<td><?
if(isset($_FILE S['img']) && !$err_msg)
{
echo myimage($img,20 0,200);
}
?>
</td>
</tr>
</table></td>
<td valign="top"><t able width="70%" border="0">
<tr>
<td width="25%" valign="top" nowrap><div align="right">A dd message to your photo&nbsp;:&nb sp; </div></td>
<td align="left" valign="top"><t extarea name="photomsg" style="width:16 0p" ></textarea>
<input name="input1" type="hidden" id="input1" value="0,0,0" onClick="change url();" />
</td>
</tr>
<TR>
<td align="right">S elect the text color :</td>
<td><a href="javascrip t:TCP.popup(doc ument.forms['process_img'].elements['input1'])"><img width="15" height="13" border="0" alt="Click Here to Pick up the color" src="colorpicke r/img/sel.gif" /></a></td>
</TR>
<TR>
<td align="right">S elect the text size :</td>
<td><select name="txtsize" >
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
</select>
</td>
</TR>
<TR>
<td align="right">S elect the text font :</td>
<td><select name="font" onChange="chang eimg(this.selec tedIndex)" >
<option value="1.ttf">f ont1</option>
<option value="2.ttf">f ont2</option>
<option value="3.ttf">f ont3</option>
<option value="4.ttf">f ont4</option>
<option value="5.ttf">f ont5</option>
<option value="6.ttf">f ont6</option>
<option value="7.ttf">f ont7</option>
<option value="8.ttf">f ont8</option>
<option value="a.ttf">f ont9</option>
<option value="arriere_ garde.ttf">font 10</option>
<option value="Linja.tt f">font11</option>
<option value="glidergi rls.ttf">font12 </option>
</select>
<table class="four" >
<tr>
<td><span id="img11">
<img name="fontimg" src="fonts/font1.JPG" width="200" height="50">
</span>
</td>
</tr>
</table> </td>
</TR>
<tr>
<td width="25%" valign="top" nowrap><div align="right">S tart your text(X)&nbsp;:& nbsp; </div></td>
<td align="left" valign="top"><i nput type="text" name="xdir" id="xdir" value="10" style="backgrou nd:#FFCCFF">
up to
<?=$imgsize[0]/2?>
(Number)</td>
</tr>
<tr>
<td width="25%" valign="top" nowrap><div align="right">S tart your text(Y)&nbsp;:& nbsp; </div></td>
<td align="left" valign="top"><i nput type="text" name="ydir" id="ydir" value="10" style="backgrou nd:#FFCCFF" onBlur="createb anner();">
up to
<? if($imgsize[1])echo ($imgsize[1]-20);?>
(Number)</td>
</tr>
<tr>
<td valign="top"><d iv align="right">S ize&nbsp;:&nbsp ;</div></td>
<td align="left" valign="top"><?
$sql="select * from img_size";
$res=mysql_quer y($sql);
?>
<select name="size">
<option value="0" selected="selec ted">__Select__ </option>
<?
while($row=mysq l_fetch_object( $res))
{
echo "<option value='$row->id'>".$row->size." - &pound;".$ro w->price."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td valign="top"><d iv align="right">M aterial&nbsp;:& nbsp;</div></td>
<td valign="top"><?
$sql="select * from material";
$res=mysql_quer y($sql);
?>
<select name="material" >
<option value="0">__Sel ect__</option>
<?
while($row1=mys ql_fetch_object ($res))
echo "<option value='$row1->id'>".$row1->material." - &pound;".$ro w1->price."</option>";
?>
</select></td>
</tr>
<tr>
<td valign="top"><d iv align="right">Q uantity&nbsp;:& nbsp;</div></td>
<td valign="top"><s elect name="quantity" >
<option value="0" >0</option>
<?
for($i=1;$i<=25 ;$i++)
echo "<option value='$i'>$i</option>";
?>
</select></td>
</tr>
<tr>
<td valign="top">&n bsp;</td>
<td valign="top">&n bsp;</td>
</tr>
<tr>
<td colspan="2" align="center"> <div id="checkavaild iv">
<?
$_SESSION['imgtemp']=$upath;
if(isset($_FILE S['img']) && !$err_msg)
{
echo "<input type='hidden' name='path' value='".$upath ."'>";
?>
&nbsp;&nbsp; <a href="index.php ?del=1&img=<?=$ upath; ?>">Delete Image</a>
<? }?>
</div></td>
</tr>
<tr>
<td valign="top">&n bsp;</td>
<td valign="top">&n bsp;</td>
</tr>
<tr>
<td colspan="4" align="center" valign="top">
<input type="submit" name="order" value="Continue to Checkout">
&nbsp; &nbsp;
<input type="button" name="cancel" value="Cancel"
onClick="return sess_del();"></td>
</tr>
</table></td>
</tr>
</form>
</table></td>
<td width="13px">&n bsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td valign="bottom" height="131"><? include("footer .php"); ?></td>
</tr>
</table>
<!-- End ImageReady Slices -->
</body>
</html>
Jul 28 '07 #1
4 2727
pbmods
5,821 Recognized Expert Expert
Heya, yatin. Welcome to TSDN!

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Jul 28 '07 #2
yatin
5 New Member
If have a two foams in my file
one is this
example....

<--------------------------------------------------------------------------------------------------------------->
<form name="upload_im g" method="post" action="" enctype="multip art/form-data">
<--------------------------------------------------------------------------------------------------------------->
And 2nd fom is this
<--------------------------------------------------------------------------------------------------------------->
<form name="process_i mg" method="post" action="checkou t.php" onSubmit="retur n valid();">
<--------------------------------------------------------------------------------------------------------------->

Now my problem is that when i submit the foam2, the image validation in my foam1 is not worked.
And i make is worked then i can not browse another image in foam1.

check it on this URl

http://acetechnologies net.com/scripts/createurposter/index.php
Jul 28 '07 #3
kovik
1,044 Recognized Expert Top Contributor
You are hardly making sense. Maybe you need to reword.

FYI, you can't submit more than one form on the same page.
Jul 28 '07 #4
pbmods
5,821 Recognized Expert Expert
Heya, yatin.

You might want to combine the two form processors into a single file.

Or, you can make it a two-step process, where the User Uploads the image first, and if the image checks out, he is then taken to the checkout form page.
Jul 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
4427
by: Beowulf | last post by:
Hi Guru's, I have a query regarding using PHP to maintain a user profiles list. I want to be able to have a form where users can fill in their profile info (Name, hobbies etc) and attach an image, which will upload the record to a mySql db so users can then either view all profiles or query.. I.e. show all males in UK, all femails over 35 etc. Now, I'm not asking for How to do this but more what would be the best way? I've looked at...
4
16225
by: Kenny | last post by:
I have been trying to write a script that will increase the size of and image when you mouse over it, and decrease it to original size, when you mouse out. After a couple of attempts, this is what I've come up with. In this example, there are 5 images (0 thru 4) all with a height of 80px. When you mouse over an image, it changes the growingImage variable equal to the number of the image you mouse over, when you mouse out, it sets it to 5,...
6
16082
by: Haines Brown | last post by:
I find that when I use list-style-image with galeon or mozilla, padding is inserted between the symbol image and the following list text, while under IE 5.0 it seems to be inserted before the image instead of after it. li.up { list-style-image: url(../bin/arrow.png); height: 1.4em; margin-left: -0.4em; }
0
1308
by: sakieboy | last post by:
In ASP.Net VB, is there a way to capture a Click on image event? Currently, I have a user control that consists of a button, calendar, and text box. User selects the button and the calendar displays (preserving real estate). Anyway, I have a few validations within the actual ASPX form. If I set my CausesValidation to "False" within my User Control, and I hit the "enter key" the validation of my items do not occur and it appears as if I...
2
4971
by: ganesh kolappan | last post by:
Hi is there any way i can call a clientside function for validation onClick of a Image or imagebutton? Right now my image or imagebutton is submitting to the server, even it return false from the clientside function. my sample code has, ..aspx code: -------------
3
2944
by: Conrad | last post by:
Hi, I was wondering, are there any recommended PHP scrips for performing image code verification? I have found a few but I wanted to check what others are using in this area. Thanks in advance, -Conrad
5
3231
by: paulmcnally | last post by:
Hi, I need a javascript RegExp for image file validation from a file upload form. I need to allow image files only (jpeg/jpg/gif/png) can anybody help me please? thanks,
16
2897
by: browntown | last post by:
so I have this application I'm nearly finished with. The only thing the client has requested is the ability to submit the form by pressing "enter". I didn't think this would be a huge pain in the ass and the app will be used internally so I'm not too worried about users who aren't using javascript. I'm using the following javascript to detect whether or not they've hit enter: if(document.layers) {
9
4687
hsriat
by: hsriat | last post by:
How can I add my validation script to this file upload code? Validation Script:function validate(frm) { if (!/(\.(gif|jpg|jpeg|png))$/i.test(frm.file.value)){ alert('Invalid file type.\nPlease attach a valid image file'); frm.file.focus(); return false; } return true; }
0
10039
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11359
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10928
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
8102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5944
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3370
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.