Problem in Upload image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahia307
    New Member
    • Jun 2007
    • 32

    Problem in Upload image

    hi

    i want to upload image with epoch date Concatenate. image is load successfully. but when i does not want to image upload then epoch date is store in database

    i use this code

    if (isset($_FILES['photo1']['name'])) {
    $mode = '0777';
    $photo1 = $epoch.$_FILES['photo1']['name'];
    $image1 = $uploadDir.$pho to1;
    move_uploaded_f ile($_FILES['photo1']['tmp_name'],$image1);
    chmod ($image1, octdec($mode));
    }

    if any body have idea about it
  • harshmaul
    Recognized Expert Contributor
    • Jul 2007
    • 490

    #2
    Hi,
    You need to help me understand what you mean.

    Does the file uploads correctly?

    I think you mean that when the form is submited without a file attached the epoch still gets inserted into the DB.
    If this is the case you need to check your queries.

    Comment

    • rahia307
      New Member
      • Jun 2007
      • 32

      #3
      Originally posted by harshmaul
      Hi,
      You need to help me understand what you mean.

      Does the file uploads correctly?

      I think you mean that when the form is submited without a file attached the epoch still gets inserted into the DB.
      If this is the case you need to check your queries.

      hi

      i use this query for insert photo in database
      $sql = "INSERT INTO tbl_photo (photo) VALUES ('$photo')";


      probelm is that what when the form is submited without a file attached the epoch still gets inserted into the DB.

      help me for this probelm.

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Please post the full relevant code.

        Using the code tags!!

        Refer to the forum guidelines if you dont know how to do this.

        Comment

        • harshmaul
          Recognized Expert Contributor
          • Jul 2007
          • 490

          #5
          You need to submit all of the relevent code.

          However i think you are assigning the value to $photo, and running the query regardless of whether or not the file is uploaded.

          Put the upload code block in to a function that returns a boolean true or false whether the file was uploaded or not, and use that boolean to know whether or not to do the insert.

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            try this tutorial from the guys at http://www.w3schools.c om. It shows you how to properly upload a file; validation, etc...

            You'll also find many other tutorials from that site.

            Comment

            Working...