I want to create a form to submit a product which has a features to upload images inside the form.
my difficulties are :
When working with uploading data,say, image. you should add the enctype form as others suggested.
Here's the uploader script of Javascript as follows:
Place the scriptabove wherever you wish,e.g. above submit button.
UPDATED: Codes to upload image in PHP (for ex.):
$uploadpath='../usrphoto/'; //image path
$allowtype=array('gif','jpg','png');
$allowsize=71250;
if(isset($_FILES['file']) && strlen($_FILES['file']['name']) > 1){
$uploadpath=$uploadpath . basename( $_FILES['file']['name']);
$sepext=explode('.', strtolower($_FILES['file']['name']));
$type=end($sepext);
if(!in_array($type, $allowtype)){
echo "";
header("Location: http://www.mywebsite.com/");
}
elseif ($allowsize>71250){
echo "";
header("Location: http://www.mywebsite.com/");
}
else{
if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadpath)){
echo 'successfully uploaded!';
else{
header("Location: http://www.mywebsite.com/");
}
}
}