Jump to content

setting the file field dynamically


beermaker74

Recommended Posts

hello
I hope that I have an easy question. I have a page that allows images and captions to be uploaded. The images get uploaded and the image names get inserted into my database. It then transfers them to a display page. On this page you can see the images you just uploaded plus the captions. I have set up the page to let users update the captions and images. This is where my problem is. I have the images being dynamically displayed, Then I have the image upload file field just below the image. Plus the caption field below that. I have 5 image fields. So if I browse and upload on one of the file fields, it sets all the other images to blank. So if the user wants to update any of the images, they have to update all of them or it doesnt work. So I thought I could just set the file fields data binded to the url I have in the recordset. So if they only change one photo field then that would be the only one that changes. I inserted the value from the bindings panel in design view in dreamweaver. It looks like it is set but it doesnt seem to work. Here is an example of the file field code

<label for="image2">File 2:</label>
        <input name="image[]" type="file" id="image2" value="<?php echo $row_Recordset1['photo2url']; ?>" />

So if there is any way to set this value it would make my life a whole lot better. If this is not the way I should go about this task. Then please let me know. MY main goal is to let the user manage photos for a real estate listing that are stored in a folder unique to that listing.
thanks
Link to comment
Share on other sites

so if I cant set the value dynamically. How should I go about doing this. I just want the user to be able to change images they have just uploaded. I need this value inserted into my database. I can probably display the contents of the folder. But how would I go about allowing  them to delete photos and add new ones. Once again I need to keep track of the images so I can add captions and later display them in a slideshow. Im open to anything.
thanks
Link to comment
Share on other sites

without going into the complexities ofthe script. I dont think displaying the value is going to help me at all. I appreciate your help though.
so this is what I am trying to do. I have set up a variable above my sql update statement. I am then going to insert this variable into my statement. What I want to do is write an if else statement to test if the image file field has any data in it. ie they browsed to a new image and want to change the one they have. So if (file field 1 is blank) then $photo1url = my recordset photo1url. else $photo1url = $_FILES['image']['name']['1']; Does this make sense? AmI creating too much work for myself. Forgive me if I am going about this issue in a convoluted way. I am stiil learning php
thanks
Link to comment
Share on other sites

i was able to set the input above the update statement with

if (!$_FILES['image']['tmp_name'][0])
{
$photourl1 = $row_Recordset1['photo1url'];
}
else {
$photourl1 = $_FILES['image']['name']['0'];
}

hopes this helps

it might not be the best way but it works. if anybody else has any ideas i'll gladly try them
thanks
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.