0
      <form method="post" action="" enctype="multypart/form-data">
        <div class="row" style="margin-left:70px">
        <p>Carousel Number</p>
          <select name="carousel_num">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="2">3</option>
          </select>
        </div>
        <input type="file" name="pic">
        <input type="submit" name="submit" class="btn btn-primary" value="Upload">
      </form>
<?php
if(isset($_POST['submit'])){
  $carousel_num = $_POST["carousel_num"];
  $tmpname = $_FILES["pic"]['tmp_name'];
  $filename = $_FILES["pic"]['name'];
  $file_ext_arr = explode(".",$filename);
  $file_name = $file_ext_arr[0];
  $ext = end($file_ext_arr);
  if($ext == "jpg" || $ext == "png" || $ext == "jpeg" || $ext == "gif"){
    move_uploaded_file("Carousel_$carousel_num","./upload/".$ext);
    echo "<script>history.go(-1);</script>";
  }else{
    echo "<script>alert(\"only 'jpg, png, jpeg, gif' file is permitted.\");history.back(-1);</script>";
  }
}
?>

Hi guys, This code make an error

Notice: Undefined index: pic in /Applications/MAMP/htdocs/astral/special.php on line 49

like this. I think, there is no spelling mistake. I don't know what Should I do to make it work.

Please help me!!

1
  • See my answer hope it helps Commented Aug 22, 2014 at 6:03

2 Answers 2

2

It should be enctype="multipart/form-data"

<form method="post" action="" enctype="multipart/form-data">
Sign up to request clarification or add additional context in comments.

1 Comment

@OhHyeonJun Great to help you accept my answer if it helps you to say to others yours is solved
1

It is not enctype='multypart/form-data'. The correct one is enctype='multipart/form-data'.

<form method="post" action="" enctype="multipart/form-data">

5 Comments

i think both are same :) , i mean to say .. what you have type " It is not enctype='multipart/form-data'. The correct one is enctype='multipart/form-data' "
your answer is the same to mine
Ok you changed now .. :)
@JohnRobertson..ohh John I was typing my answer at that time. I saw your answer only after I submitted my answer. Sorry.
@user3209031..It was a typo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.