Results 1 to 2 of 2

Thread: Getting round a form in a form

  1. #1
    Join Date
    Mar 2007

    Getting round a form in a form

    I'm trying to insert an upload section within a Wordpress post page that gets round the upload file size limit set by the shared hosting.

    I put together a form and php script and got the upload bit working. When I went to use it in Wordpress I found that I was unable to use a form within another form.

    <script type="text/javascript">
    // Javascript to sort out a couple of fields
     function triggerSubmit(e){
        var textbox1 = document.getElementById('uploadedfileName');  
        var textbox2 = document.getElementById('firstname');  
        textbox2.value = textbox1.value;
        textbox1.value = '';
        return false; // Prevent form auto submittal
    <form id="myform" enctype="multipart/form-data" action="upload-control.php" method="post" target="foo" onSubmit="window.open('', 'foo', 'width=450,height=300,status=yes,resizable=yes,scrollbars=yes')" method="POST">
        Firstname: <input type="text" id="firstname" name="firstname" />
        Choose a file to upload: <input name="uploadedfile" type="file" id="uploadedfile" onChange="uploadedfileName.value=uploadedfile.value"/><br /><br>
        <input name="uploadedfileName" type="hidden" id="uploadedfileName" tabindex="99" size="1" />
        <input type="submit" name="submit" value="Upload File" onClick="triggerSubmit()" />
    The form works fine on its own and the php file parses all the data and uploads a file via ftp

    However if I insert this form in to the Wordpress Admin New Post Page, it won't work because it's my form inside their form. I need a work around but my javascript skills are pretty poor.

    The php script uses these variables from the form so they need to be passed via javascript...
    // $output_form = false; // Set output_form variable to false by default.
    $fileInfo = $_FILES['uploadedfile'];  // Make an array out of the file information.       store in $fileInfo
    $filePath = $fileInfo['tmp_name'];  // Take the file path name and store in $filePath.
    $fileName = basename($_FILES['uploadedfile']['name']);    // Get filename from path
    // Add a check for file name for spaces or dashes - - -   <---Those things.  Return an error message if spaces/dashes are found.
    // Add a check form for valid fields.
    //$destination_path = $_SERVER['DOCUMENT_ROOT'].'\\'.$fileName; 
    $destination_path = "dd/$fileName";  
    I've been trying to turn the form in to a normal href link but I'm not sure how to pass the variables that the php script requires.

    Can anyone help?

  2. #2
    Join Date
    Dec 2005
    couldn't you remove the <form and /form> tags and add the upload-control.php file to be called by the javascript with the submits onChange in the input field?

    new AjaxUpload(btnUpload, {
    			action: 'upload-control.php

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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