Rename Images Submitted

User 2860387 Photo


Registered User
2 posts

When users fill out the form and submit their images, they also have to put in their ID number.
The images are saved to the file server and the form works perfectly.

The only thing I would like to do is during the save, name the image that is being uploaded to the ID number they entered with the form.

Is there any way of taking that $idnum and making that the filename of the image as it's saved?
User 187934 Photo


Senior Advisor
20,186 posts

At this time you don't have that ability. I imagine you could try to alter the image name after they submit through the $_SESSION variables on a custom redirect. I haven't tried it but it should work.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2699991 Photo


Registered User
4,797 posts
Online Now

Brian Bowers wrote:
When users fill out the form and submit their images, they also have to put in their ID number.
The images are saved to the file server and the form works perfectly.

The only thing I would like to do is during the save, name the image that is being uploaded to the ID number they entered with the form.

Is there any way of taking that $idnum and making that the filename of the image as it's saved?


Just a thought why not ask the users to name the image with their ID before they upload it
Mastering The Understanding With Hands-On Learning
NEW TO "COFFEECUP SITE DESIGNER" FOUNDATION 6 FRAMEWORK?
STUCK ON SOMETHING?

LEARNING & UNDERSTANDING "THE HOW TO"? THE WHY'S & THE WHEREFORE'S?
WITH WAYAN'S STEP BY STEP TUTORIALS
Contact Me For One To One Assistance
https://alphathemes.coffeecup.com/forms … an%281%29/
User 187934 Photo


Senior Advisor
20,186 posts

Wayan Jaya wrote:


Just a thought why not ask the users to name the image with their ID before they upload it

The formbuilder renames images on upload.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2699991 Photo


Registered User
4,797 posts
Online Now

Eric Rohloff wrote:
Wayan Jaya wrote:


Just a thought why not ask the users to name the image with their ID before they upload it

The formbuilder renames images on upload.


Hi Eric
so is that made possible by using that thingy you suggested if so could you let me know what to put I will have a use for that at some point soon,, but I am totally stupid when it comes to that sort of coding PLEASE :)
Mastering The Understanding With Hands-On Learning
NEW TO "COFFEECUP SITE DESIGNER" FOUNDATION 6 FRAMEWORK?
STUCK ON SOMETHING?

LEARNING & UNDERSTANDING "THE HOW TO"? THE WHY'S & THE WHEREFORE'S?
WITH WAYAN'S STEP BY STEP TUTORIALS
Contact Me For One To One Assistance
https://alphathemes.coffeecup.com/forms … an%281%29/
User 187934 Photo


Senior Advisor
20,186 posts

The formbuilder uses $_SESSIONS to store the variables. Those variables are available to work with after submit. You can use the custom redirect option to alter the variables. You should be able to look for the image by name using the variables and then change it to the value of another variable being used in the form. I'll see if I can through together some example code if I get a chance. I have several projects going at the moment.

I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2699991 Photo


Registered User
4,797 posts
Online Now

Eric Rohloff wrote:
The formbuilder uses $_SESSIONS to store the variables. Those variables are available to work with after submit. You can use the custom redirect option to alter the variables. You should be able to look for the image by name using the variables and then change it to the value of another variable being used in the form. I'll see if I can through together some example code if I get a chance. I have several projects going at the moment.



no rush Eric thank for everything

Its for a future project but a little bit of practice first won't do any harm

thanks again
Mastering The Understanding With Hands-On Learning
NEW TO "COFFEECUP SITE DESIGNER" FOUNDATION 6 FRAMEWORK?
STUCK ON SOMETHING?

LEARNING & UNDERSTANDING "THE HOW TO"? THE WHY'S & THE WHEREFORE'S?
WITH WAYAN'S STEP BY STEP TUTORIALS
Contact Me For One To One Assistance
https://alphathemes.coffeecup.com/forms … an%281%29/
User 187934 Photo


Senior Advisor
20,186 posts

Here ya go.
I did some testing and the form builder renames images sometimes but not always so your should always use the script to make sure.
I setup my form to do a custom redirect to the page holding this script. The script is setup to be in the same location as your formname.php. Adjust the paths if your going to place it someplace else. Adjust the rename-photo-upload to the name of your form. Adjust the Redirect to the location of your page holding the form embed script. Mine is in the same location as the formname.php on a page named index.html.
<?php
session_start();
// Gets the post array
$post = $_SESSION['post'];
// Gets the original file name
$original_photo_name = $post['photo'];
// Gets the persons name in the input
$persons_name = $post['your_name'];
// Gets the extension of the file. Adjust path if needed
$path_parts = pathinfo('/rename-photo-upload/storage/files/'.$original_photo_name);
$extension = $path_parts['extension'];
// Renames the file to that of the input. Adjust path if needed
rename('rename-photo-upload/storage/files/'.$original_photo_name, 'rename-photo-upload/storage/files/'.$persons_name.'.'.$extension);
// Redirect back to form
header("Location: index.html");
die();
?>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.