Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Nov 2011
    Location
    South Africa
    Posts
    60
    Thanks
    14
    Thanked 0 Times in 0 Posts

    upload to mysql database

    I am try to Upload a File and write to MySQL but I keep getting an error Undefined index: ../upload two parts of my code can anyone see where I am going wrong?

    PHP Code:
    //This is the directory where files will be saved 
     
    $target "upload/"
     
    $target $target basename$_FILES['../upload']['name']); 
    PHP Code:
    //Writes the pdf to the server 
     
    if(move_uploaded_file($_FILES['../upload']['tmp_name'], $target)) 
     { 

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Post your HTML form.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New Coder
    Join Date
    Nov 2011
    Location
    South Africa
    Posts
    60
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Code:
    <form class="contact_form" enctype="multipart/form-data" action="php/add.php" method="POST">
                <ul>
                <li>First Name: <input type="text" name="firstname" required></li>
                <li>Surname: <input type="text" name = "surname" required></li> 
                <li>address: <input type="text" name = "address" required></li> 
                <li>PDF Name: <input type="file" name="pdf_name" required></li>
                <input type="submit" value="Add"> 
                </ul>
                </form>

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    The name is pdf_name, not ../upload. You should find that within the $_FILES superglobal.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    New Coder
    Join Date
    Nov 2011
    Location
    South Africa
    Posts
    60
    Thanks
    14
    Thanked 0 Times in 0 Posts
    I want the uploaded files to store in a folder called uploads where do I define that? I changed the pdf_name to upload but i'm still getting the errors, any suggestions?

    Notice: Undefined index: ../upload/
    Last edited by helen11; 12-11-2013 at 02:12 PM.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You would define that in your target. In the move, you'll need to give the target a filename as well.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •