close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Best photo upload naming convention?

Thread began 10/26/2013 3:10 pm by Justin@AdventDesign | Last modified 11/05/2013 11:06 am by Justin@AdventDesign | 764 views | 4 replies |

Justin@AdventDesign

Best photo upload naming convention?

I often have record insertion with a photo upload included. Typically, I've just been leaving the original file name intact, and in the update form, having replacement photos renamed by appending a number if duplicate. This has resulted in a lot of extra image files and a really messy collection of photos on the server.

I'd like to apply a more strict naming convention for the photos, and then replace rather than rename the photos with any updates.

The most obvious answer would be to use the unique record ID, but how do I do that since on the insert page, the ID# isn't generated until upload? I've seen another post that seems to speak to this, but I'm having trouble following how to go about it.

Sign in to reply to this post

weboholic

You can get the next possible ID if you ask the DB information_schema

SELECT
information_schema.`TABLES`.AUTO_INCREMENT
FROM
information_schema.`TABLES`
WHERE
information_schema.`TABLES`.TABLE_NAME = '{Your_Table_Name}'

but this is sensible in multiuser environments

or just

1. add a new (empty) record
2. upload the file and use the given back ID from the session varible
3. update the record

Sign in to reply to this post

Justin@AdventDesign

Sorry, but I come from the design side and know just enough PHP to be dangerous. Could you show how I might set a variable with that select statement ?

Sign in to reply to this post

weboholic

<?php require_once('Connections/db.php'); ?>
<?php
mysql_select_db($database_db, $db);
$query_rsGetNextID = "SELECT information_schema.`TABLES`.AUTO_INCREMENT FROM information_schema.`TABLES` WHERE information_schema.`TABLES`.TABLE_NAME = 'dbImages'";
$rsGetNextID = mysql_query($query_rsGetNextID, $db) or die(mysql_error());
$row_rsGetNextID = mysql_fetch_assoc($rsGetNextID);
$totalRows_rsGetNextID = mysql_num_rows($rsGetNextID);

// This is your next available ID for dbImages

$myNextID = $row_rsGetNextID['AUTO_INCREMENT'];

mysql_free_result($rsGetNextID);
?>

You have to replace dbImages (my table name) with your table name

As i said if this is a multi user environment you can not be sure that this is YOUR next ID.
Another user can insert a record and the next available ID change.

Better use Data Bridge to

1. Add a new record, Data bridge ask you for the session name for "Save Inserted ID in Session" - dbImagesInsertID for example
2. Insert file upload and use in file name my_file_name_<?php echo $_SESSION['dbImagesInsertID']; ?>
3. Update the record with imagename/filename/... using informations from the upload object in bindings panel

You can do this all in the same page.

Sign in to reply to this post

Justin@AdventDesign

Thanks weboholic. This is for a back-burner project so I haven't had a chance to dig in and try your solution, but I appreciate the help!

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...