I have create a simple image editor with the effects of brightness, contrast, and desaturation etc. I have used for this pixastic functions from www.pixastic.com. The function is working successfully but I don't know how to replace the original image with the adjusted image, with effects. Here is code I have used
<script>
var pixastic_parseonload = true;
</script>
<script src="pixastic.core.js" type="text/javascript"></script>
<script src="actions/desaturate.js" type="text/javascript"></script>
<body>
<form name="form1" action="index.php" enctype="multipart/form-data" method="post">
<p>Image to use:</p>
<img id="scream" class="pixastic <?php echo #$_POST["butn1"];?>" src="Desert.jpg" alt="The Scream" width="220" height="277" name="image1">
<button value="pixastic-desaturate()" name="butn1" >Desaturate</button>
</form>
</bode>
Maybe you need to change this:
<button value="pixastic-desaturate()" name="butn1" >Desaturate</button>
with this:
<input type="button" name="pixastic-desaturate" VALUE="Click to process the image" onClick="pixastic-desaturate();">
Related
I'm working on a web application in php that allows users to upload files with a specified structure (file type could be cvs or excel sheets) and the app will extract data from the files and insert them into a database.
I can't get my app to upload files and I've been trying for 2 days, I checked the php.ini for max upload size ,max post size , file uploads on, temp directory set to /tmp which is accessible by all users.
I also checked the syntax of php and html and made sure I was using the right encoding type, I also checked the permissions of the upload directory but the _FILES variable is always empty, note : my web server is hosted on amazon ec2 running Ubuntu 14.04 LTS.
here's one of the codes I tried and it's output:
<?php
echo $_FILES['file']['error'];
print_r($_FILES);
echo $name = $_FILES['file']['name'];
?>
<html>
<header>
<title> Test Page</title>
</header>
<body>
<form action="Test.php" method="POST" enctype="multipart/formdata">
<input type="file" name="file" id="file" /><br><br>
<input type="submit" value="submit" />
</form>
</body>
<html>
and the outputted echo is only Array ( ) whether I upload a file or not.
anyone faced something like this before ?
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
session_start();
$file_tmp= $_FILES['image']['tmp_name'];
header("Test.php");
}
?>
<html>
<header>
<title> helllllllo </title>
</header>
<body>
<form action="form-validation" method="POST" enctype="multipart/form-data" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" >
<div class="form-row form-input-name-row">
<label>
<span>Profile Image</span>
<input type="file" name="image" id="file" onchange="readURL(this);" data-val="true" style="margin-bottom:10px;" />
<div class="form-row form-input-name-row">
<img id="blah" src="#" alt="your image" style="width: 100px; display: none; margin-bottom:10px;" />
</div>
</div>
<input type="submit" value="submit" />
</form>
<script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').show().attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</body>
</html>
I want to make code for making comments and share it to others.
When I run this code and write a comment it prints nothing.
Note: I got this code from a tutorial on youtube.
<html>
<head>
<title>hesham</title>
</head>
<script src="jquery-1.6.1.min.js" type="text/javascript"></script>
<script type="text/javascrpt">
function get()
{
var input = $('#cmt').val();
$('#an').prepend(input);
};
</script>
<body>
<form name="frm">
<input type="text" name="cmt" id="cmt" /><input type="button" value="post" onclick="get()" />
</form>
<div id="an" style="width:300px">
</div>
</body>
</html>
The problem is with this:
<script type="text/javascrpt">
^-- // missing the "i"
It's mispelled, a slight typo.
Change it to:
<script type="text/javascript">
and it will work.
(tested)
You could also place your jQuery in <head></head> yet, my test worked either way.
I going to design 2 php page,one is personal detail form must filled by the users and another one is display all personal details where they had been done in personal detail form after submit.My problem is that the image that had submitted didn't display on the 2nd page.What wrong with my code?My code shown as below:
<!DOCTYPE html>
<head>
<title></title>
//for preview a image
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
</script>
</head>
<body>
<form name="rform" method="get" action="researchers.php">
<h4>Researchers Profile</h4>
<fieldset>
<legend>Personal Details</legend>
<form id="form1" method="get" action="researchers.php" enctype="multipart/form-data" id="pro_image">
<input type='file' onchange="readURL(this);" name="image" id="image"/>
<br><img id="blah" src="profile pic.jpg" alt="your image" width="160px" height="120px"/><br/>
</form>
<input type="submit" name="savebtn" value="Save"/>
</form>
The researchers.php page
<?php
$name=$_FILES['image']['name'];
$tmp=$_FILES['image']['tmp_name'];
$new=time().$name;
$new="upload/".$new;
move_uploaded_file($tmp,$new);
if($_FILES['image']['error']==0)
{
?>
<br /><img src="<?php echo $new;?>" width="100" height="100"/>
<?php
}
?>
Try changing your <form> method to post as from the php manual for $_FILES - http://www.php.net/manual/en/reserved.variables.files.php
Description
An associative array of items uploaded to the current script via the HTTP POST method.
You will need to also add enctype="multipart/form-data" - http://www.w3.org/TR/html401/interact/forms.html#adef-enctype
<form name="rform" method="post" action="researchers.php" enctype="multipart/form-data">
see also http://www.php.net/manual/en/features.file-upload.post-method.php
Okay so I'm confused and lost and have no idea of what I am doing, basically here is my code:
HTML/JavaScript:
<img src="Images/Question1.png" usemap="#mainMap" id="main"/>
<map name="mainMap" id="mainMap">
<area shape="rect" coords="82,192,196,242" onclick="incorrectAnswer()" />
</map
function incorrectAnswer() {
document.getElementById("incorrectVid").style.display="block";
document.getElementById("incorrectVid").play();
document.getElementById("answer_id").value=id;
document.forms["answer_send"].submit();
}
<form id="answer_send" name="answer_send" action="answersend.php" method="POST">
<input type="hidden" id="answer_id" name="answer_id" value="10"/>
<input type="submit" value="Submit" />
</form>
PHP:
$id=$_POST['answer_id'];
echo $id
I have no idea why this is not working any ideas/help?
To grab values submitted via GET/POST you need to assign the name property to your input fields. Try the below:
The HTML and JS
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script>
function incorrectAnswer() {
document.forms["answer_send"].submit();
}
</script>
</head>
<body>
<img src="none.jpg" alt="placeholder" width="200" height="200" onClick="incorrectAnswer();">
<form id="answer_send" name="answer_send" action="form.php" method="POST">
<input type="hidden" id="answer_id" name="answer_id" value="10"/>
</form>
</body>
</html>
The PHP
<?php
$id=$_POST['answer_id'];
echo $id;
?>
Note: Your AREA element is not going to work unless you assign it to something.
Your JavaScript function must be within tags or you'll receive errors.
The HTML/PHP part of this is working fine... You are experiencing these issues due to the following three lines...
document.getElementById("incorrectVid").style.display="block";
document.getElementById("incorrectVid").play();
document.getElementById("answer_id").value=id;
where is your name attribute ?
Every input must have a name attribute to retrieve it on php
and your html code must look like this:
<form id="answer_send" name="answer_send" action="answersend.php" method="POST">
<input type="hidden" id="answer_id" name="answer_id" value="10"/> </form>
For some reason it's not changing the action of the forum. I have some code to change the action of a form when a button is clicked:
function changeForm(event){
alert("Before: "+jQuery("#franchiseform").attr("action"));
jQuery("#franchiseform").attr("action", "franchisepreview.php");
alert("After: "+jQuery("#franchiseform").attr("action"));
jQuery("#franchiseform").submit();
}
The binding:
jQuery("input.preview").bind("click", changeForm);
The form:
<form method="post" enctype="multipart/form-data" action="franchiseinsert.php" class="insert-new" id="franchiseform">
The buttons:
<input type="button" value="Preview" id="preview" name="preview" id="preview" class="preview" /><input type="submit" value="Insert" />
First off, you need to clean up the
<input type="button" value="Preview" id="preview" name="preview" id="preview" class="preview" />
to:
<input type="button" value="Preview" id="preview" name="preview" />
as an input should not have multiple id attributes and you should not use classes and id's with the same name. This could be one reason why you're having problems. Then I used the following code and the action url was actually changing:
<html>
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#preview").bind("click", changeForm);
function changeForm(event){
alert("Before: "+ $("#franchiseform").attr("action"));
$("#franchiseform").attr("action", "franchisepreview.php");
alert("After: "+ $("#franchiseform").attr("action"));
$("#franchiseform").submit();
}
});
</script>
</head>
<body>
<form method="post" enctype="multipart/form-data" action="franchiseinsert.php" class="insert-new" id="franchiseform">
<input type="button" value="Preview" id="preview" name="preview" />
<input type="submit" value="Insert" />
</form>
</body>
</html>
Unless you stripped out too much, it looks like you need to put your "after" call into a function called "changeForm", which is what you are binding to the click event.
otherwise, keep chaining:
jQuery("input.preview").bind("click", function(){
jQuery("#franchiseform").attr("action", "franchisepreview.php"));
jQuery("#franchiseform").submit();
});
It turns out that this is a Firefox / Mac specific bug. It works on other platforms and browsers, but not this specific computer for some reason. It could be an extension conflict or something else, I'll simply use another browser.