close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Creating Dynamic Upload Folders

Thread began 6/15/2011 4:21 pm by Jenny I | Last modified 6/23/2011 1:28 pm by Jason Byrnes | 1960 views | 12 replies |

Jenny I

Creating Dynamic Upload Folders

I posted in this thread before asking about creating dynamic folders
showthread.php?t=17941&highlight=create+folders

This was before I realised thate UE/DFP could create it.

I would like to create a dynamic folder based on a 'categoryname' recordset row. The problem is like in the linked thread is the dynamic file name has spaces in it.

Would you be able to help me integrate preg_replace("/[^a-zA-Z0-9s]/", "", $string) in my code.

say for example i set my dynamic folder path to

  ../resources/uploads/<?php echo $row_WADAmyrecorset['categoryName']; ?>/  



how would i configure preg_replace to replace spaces with underscores _

Thanks in advance

Sign in to reply to this post

Jason ByrnesWebAssist

change:

php:
<?php echo $row_WADAmyrecorset['categoryName']; ?>




to:

php:
<?php echo(preg_replace("/[^a-zA-Z0-9s]/"""$row_WADAmyrecorset['categoryName'])); ?>
Sign in to reply to this post

Jenny I

Hi Jason

How would this look on a form post would it be-

  <?php echo(preg_replace("/[^a-zA-Z0-9s]/", "",((isset($_POST["trainingSeriesTitle"]))?$_POST["trainingSeriesTitle"]:""))) ?>  
Sign in to reply to this post

Jason ByrnesWebAssist

for a post it would be:

php:
<?php echo((isset($_POST["trainingSeriesTitle"]))?preg_replace("/[^a-zA-Z0-9s]/"""$_POST["trainingSeriesTitle"]):""?>
Sign in to reply to this post

Jenny I

Hi Jason

Could you briefly direct me on how I would use UE/DFP to create a dynamic folder. This Is what i think I should do

1. I have a dynamic menu and I use javascript to put the label in a hidden field
2.in DFP settings for upload folder i put

  ../Media-Library/Resources/<?php echo ((isset($_POST["folderCreate"]))?preg_replace("/[^a-zA-Z0-9s]/", "", $_POST["folderCreate"]):""); ?>/images/  



folderCreate is the name of my hidden field. When I click submit the folder is not created and my file is not in the database.

Would you be able to help maybe this is not the create procedure

Sign in to reply to this post

Jason ByrnesWebAssist

if this is not working I would question whether the javascript is properly sending the value to the hidden form element.

to troubleshot, add the following code at line one of your page:

php:
<?php

error_reporting
(E_ALL);
ini_set('display_errors','on');
?>
<?php
if($_SERVER['REQUEST_METHOD'] =="POST") {
  echo(
"<pre>");
  
var_dump($_POST);
  echo(
"</pre>");
}
?>



this will turn error reporting on so we can see any errors that are occurring, and output the posted values from the form (this is going to cause the headers already sent error to occur, but we can ignore that one) so we can see if the hidden element is being populated by the script..

Sign in to reply to this post

Jenny I

Hi Jason

The hidden form with javascript is the problem. If validation fails the value on the hidden form element is lost, unless I select the menu item again. I tried using validated binding on the hidden field but it will not work.

This is a sample of the javascript I am using

  The select

<select name="trainingResourceCatID" title="<?php echo(ValidatedField("trainingSeriesInsert_300","trainingResourceCatID")) ?>" onchange="setValue(this.options[this.selectedIndex].text, 'folderCreate');" >
</select>

the hidden field

<input id="folderCreate" type="hidden" name="folderCreate" >

the field

<script type="text/javascript">
function setValue(theVal, theInput){
document.getElementById(theInput).value = theVal;
}
</script>  



If validation passes first time it all works perfectly

Sign in to reply to this post

Jason ByrnesWebAssist

which validated entries binding did you use? uses the folderCreate validated entries binding,

Sign in to reply to this post

Jenny I

Yes thats the one I used but unfortunately it cause the javascript onchange to stop working. Do you happen to know an alternative way I can do this?

Sign in to reply to this post

Jenny I

More Problems

I decided to totally scrap the idea of a dynamic folder for now and have reverted back to uploading into a staic image folder.

However I am having further problems. My server validations have stopped working and DFP upload does not work at all. At first my validation was telling me that the file was exceeded the max file size I set. This was not the case. Now it does not work at all. I can only update and insert if I do not upload an image. Could this be because I am using file manager in the same form.

Secondly on update pages, file manager loses its value unless I upload again. Do I need to set a hidden field to store the value like I do on DFP?

I have attached my pages.

Your help is greatly appreciated

Sign in to reply to this post
loading

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...