Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Inserting filename into field
  • I am trying to have the uploaded file's filename inserted into a form field. I have been through multiple threads with no better success despite multiple code changes.

    So, here is what I have.

    <script type=\"text/javascript\">
    $(document).ready(function() {
    $(\"#uploadify\").uploadify({
    'uploader' : 'scripts/uploadify.swf',
    'script' : 'scripts/uploadify.php',
    'cancelImg' : 'cancel.png',
    'folder' : 'img',
    'queueID' : 'fileQueue',
    'onComplete' : function (event, queueID, fileObj, response, data) {
    $(\"#uploadedpics\").append(\"<input name='pic' value='\" + response + \"' />\"); //adds hidden form field to uploadedpics div
    },
    'auto' : true,
    'multi' : false
    });
    });
    </script>


    <form name=\"form\" action=\"process.php\" method=\"post\">
    <hr />
    Photo Uploader:<br /><br />
    <div id=\"fileQueue\"></div>
    <input type=\"file\" name=\"uploadify\" id=\"uploadify\" />
    <p><a href=\"javascript:jQuery('#uploadify').uploadifyClearQueue()\">Cancel All Uploads</a></p>
    MAKE THE IMAGE WIDTH 579px for best results!
    <br />
    <label for=\"filename\">Enter filename (ie: propertyphoto.jpg):</label>
    <input type=\"text\" name=\"filename\" id=\"filename\"><br />
    Note: The filename must be EXACTLY matched! So \"PhoTo.JpG\" <u>MUST</u> be entered as \"PhoTo.JpG\" into the text box.
    <br />
    <div id=\"uploadedpics\">
    <!-- hidden form field posts to here -->
    </div>
    <hr />
    <input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Submit\">
    </form>


    On the completion of the file upload a "1" is simply put into the text field. I want the "pic.jpg" filename put in. I think it is putting the queue number in, since it would be the first file uploaded?

    I even tried RonnieSan's code shown below but it just put a 1 in as well:

    'onComplete' : function(event,queueID,fileObj,response,data) {
    $('#filename').val(response);
    },



    I lack the javascript knowledge to understand what is wrong, so your help is very much appreciated.
    Thanks!
  • response - by default in the uploadify.php is echo "1"; Change echo"1"; on echo $name; or something else and you'l have needed resault.