Results 1 to 3 of 3

Thread: Updating File Inputs

  1. #1
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default Updating File Inputs

    Hi all...

    I'm constructing a backend in which I have a few file inputs that are uploading files to the server space + saving the filename in MySQL.

    Elsewhere in the CMS, I have a set of forms set to update perviously entered sets of data (which include the images).

    When I'd like to update other information in the set (i.e. change something besides the images) and save the info back to the MySQL or update it in this case, I lose the entries I had for the image filenames.

    The reason is obvoius...b/c I'm updating the data with blank file inputs.

    Now, since there is no value attribute for file inputs, how can I make it so that the image data isn't updated in my query unless it has been changed (i.e. it's not blank).

    Here's the PHP that I have

    PHP Code:
    $upd "INSERT INTO $page (id, category, thumbnail, banner, credits, title, author, bio, summary, article, feature, pictured) VALUES ('', '$category', '$thumbnail', '$banner', '$credits', '$title', '$author', '$bio', '$summary', '$article' , '$feature', '$pictured')"
    Bascially, thumbnail & banner are filenames from a file inputs.

  2. #2
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    If I understand the question right, there are two solutions.
    1) on the edit form, load the current values
    (this will re-load the value on submit; I like this better b/c the user can see what the value is and make changes, like editing a post on these forums.)
    2) on submit, see if the feild is blank.
    for example:
    PHP Code:
    1)
    <?php
    print "<input type='text' name='name' value='".$row['name']."'>";
    ?>

    2)
    <?php
    if($_POST['name'] != ""){ $query .= " name=\"$name\"";}
    ?>
    Last edited by Jas; 01-06-2008 at 07:49 PM.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  3. #3
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by Jas View Post
    If I understand the question right, there are two solutions.
    1) on the edit form, load the current values
    2) on submit, see if the feild is blank.
    for example:
    PHP Code:
    1)
    <?php
    print '<input type='text' name='name' value='".$row['name']."'>';
    ?>

    2)
    <?php
    if($_POST['name'] != ""){/*process feild*/}
    ?>

    Thanks.
    I did something like what I think you're describing in option 2.

    Option 1 won't work on file inputs, that was the whole dilemma. It would be a huge security risk if you could pre-fill file input fields.

Bookmarks

Posting Permissions

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