Question
Uploading image
I'm got a cool uploading images tutorial from Asfusion.com. I
got it working but this is my issue. I created a db table called
"photos", in the photos table I made two columns named "id" and
"images". I'm allowing users to login and upload images to a folder
on my server. I now want to save the name of the image that was
uploaded, to my db column named "images" aswell as save the user id
to my "id" column. I'm using SESSION.Auth.id .
I'm using a tabbed cfform to do this, what I'm trying to make happen is on one tab is the upload field and upload button, on the second tab I want to bind the images that was upload by a specifc user (called by the id) to a cfgrid and display all the images uploaded by that user. So I want to associate all the images of a specific user to there user id.
How do I send the users id through the query string to get saved to my db table called photos?
If my code is incorrect, can someone lead me in the right direction? Or is there an easier way to get what I nreed to get done?
Thanks
Rob
This is the upload code:
<cf_flashUpload label="Picture:" name="myfile2" fileTypes="*.jpg;*.png;*.gif" fileDescription="Image files" actionFile="upload.cfm" maxSize="500">
<cf_flashUploadInput buttonStyle="corner-radius: 10;" inputStyle="fontWeight:bold" inputWidth="190" uploadButton="true" uploadButtonLabel="Upload" chooseButtonLabel="Choose file" progressBar="true" progressInfo="true" required="yes" message="Please enter a valid file to upload!" />
</cf_flashUpload>
This is the processing script:
<cfif structkeyexists(form,"Filedata")>
<cffile action="UPLOAD" filefield="FileData" destination="#expandpath("\uploads")#" nameconflict="MAKEUNIQUE">
</cfif>
<CFQUERY DATASOURCE="#DataSource#">
INSERT into photos(images,id)
VALUES('#Trim(FORM.myfile2)#',
('#Trim(URL.SESSION.Auth.id)#')
</CFQUERY>
I'm using a tabbed cfform to do this, what I'm trying to make happen is on one tab is the upload field and upload button, on the second tab I want to bind the images that was upload by a specifc user (called by the id) to a cfgrid and display all the images uploaded by that user. So I want to associate all the images of a specific user to there user id.
How do I send the users id through the query string to get saved to my db table called photos?
If my code is incorrect, can someone lead me in the right direction? Or is there an easier way to get what I nreed to get done?
Thanks
Rob
This is the upload code:
<cf_flashUpload label="Picture:" name="myfile2" fileTypes="*.jpg;*.png;*.gif" fileDescription="Image files" actionFile="upload.cfm" maxSize="500">
<cf_flashUploadInput buttonStyle="corner-radius: 10;" inputStyle="fontWeight:bold" inputWidth="190" uploadButton="true" uploadButtonLabel="Upload" chooseButtonLabel="Choose file" progressBar="true" progressInfo="true" required="yes" message="Please enter a valid file to upload!" />
</cf_flashUpload>
This is the processing script:
<cfif structkeyexists(form,"Filedata")>
<cffile action="UPLOAD" filefield="FileData" destination="#expandpath("\uploads")#" nameconflict="MAKEUNIQUE">
</cfif>
<CFQUERY DATASOURCE="#DataSource#">
INSERT into photos(images,id)
VALUES('#Trim(FORM.myfile2)#',
('#Trim(URL.SESSION.Auth.id)#')
</CFQUERY>
