close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

upload-resize-send link

Thread began 8/16/2010 7:17 am by jcrockett300688 | Last modified 8/18/2010 3:10 pm by Jason Byrnes | 2059 views | 11 replies |

jcrockett300688

upload-resize-send link

I want to upload image(s), resize them, and then send link to the file(s) on the server. Everything works except I can't figure out how to send the link in UE (4.01) to the uploaded files (I have 3 upload file fields). I would prefer not to have to set up a database for it to work.

The files are sent in the email if I don't resize them and if I set the form to resize them, the files get resized as expected on the server.

Sign in to reply to this post

Jason ByrnesWebAssist

When you add the Upload File server behavior to your page, a new binding group is created on the bindings page called "Uplaoded Files(<Name of File Field>)" where <Name of File Field> is the name of the file form element. a separate binding group will be created for each file form element.

In the Uploaded Files(<Name of File Field>) binding group, there is a binding for server file name.

Also, if you have set the Upload File to create multiple copies of the file on the server, there will be separate bindings fro each copy. Each of the seperate binding will be preceded by the upload folder name for that copy.


you can use these bindings to create the link to the file in the email, for example, the code produced by the server file name binding will look similar to:

php:
<?php echo $WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]; ?>



you use this to create the file link:

php:
<a href="http://www.mydomian.com/path/to/file/<?php echo $WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]; ?>"><?php echo $WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]; ?></a>
Sign in to reply to this post

jcrockett300688

Not quite

Your code makes perfect sense... if I could find that code somewhere.

In the waue_for_1.php file, I did find:
//Attachment Entries
$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."");

But in the form.php file (where I'm using UE), the code is missing. I do see the code while I'm configuring the email attachments but when I click Finish, that code doesn't get written.

Here's what's written after configuring an upload w/file resize and then creating an email message with UE and following your instructions:

<?php require_once("../webassist/file_manipulation/helperphp.php"); ?>
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "images/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "2",
'ResizeWidth' => "800",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?>
<?php?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult1", "upload1", "2", "[NewFileName]_[Increment]", "JPG:80", $WA_UploadResult1_Params);
}
?>
<?php require_once("../webassist/email/mail_php.php"); ?>
<?php require_once("../webassist/email/mailformatting_php.php"); ?>
<?php
if (!isset($_SESSION))session_start();
if (($_SERVER["REQUEST_METHOD"] == "POST")) {
//WA Universal Email object="mail"
set_time_limit(0);
$EmailRef = "waue_form_1";
$BurstSize = 200;
$BurstTime = 1;
$WaitTime = 1;
$GoToPage = "thank.html";
$RecipArray = array();
$StartBurst = time();
$LoopCount = 0;
$TotalEmails = 0;
$RecipIndex = 0;
// build up recipients array
$CurIndex = sizeof($RecipArray);
$RecipArray[$CurIndex] = array();
$RecipArray[$CurIndex ][] = "jcrockett@somewhere.net";
$TotalEmails += sizeof($RecipArray[$CurIndex]);
$RealWait = ($WaitTime<0.25)?0.25:($WaitTime+0.1);
$TimeTracker = Array();
$TotalBursts = floor($TotalEmails/$BurstSize);
$AfterBursts = $TotalEmails % $BurstSize;
$TimeRemaining = ($TotalBursts * $BurstTime) + ($AfterBursts*$RealWait);
if ($TimeRemaining < ($TotalEmails*$RealWait) ) {
$TimeRemaining = $TotalEmails*$RealWait;
}
$_SESSION[$EmailRef."_Total"] = $TotalEmails;
$_SESSION[$EmailRef."_Index"] = 0;
$_SESSION[$EmailRef."_Remaining"] = $TimeRemaining;
while ($RecipIndex < sizeof($RecipArray)) {
$EnteredValue = is_string($RecipArray[$RecipIndex][0]);
$CurIndex = 0;
while (($EnteredValue && $CurIndex < sizeof($RecipArray[$RecipIndex])) || (!$EnteredValue && $RecipArray[$RecipIndex][0])) {
$starttime = microtime_float();
if ($EnteredValue) {
$RecipientEmail = $RecipArray[$RecipIndex][$CurIndex];
} else {
$RecipientEmail = $RecipArray[$RecipIndex][0][$RecipArray[$RecipIndex][2]];
}
$EmailsRemaining = ($TotalEmails- $LoopCount);
$BurstsRemaining = ceil(($EmailsRemaining-$AfterBursts)/$BurstSize);
$IntoBurst = ($EmailsRemaining-$AfterBursts) % $BurstSize;
if ($AfterBursts<$EmailsRemaining) $IntoBurst = 0;
$TimeRemaining = ($BurstsRemaining * $BurstTime * 60) + ((($AfterBursts<$EmailsRemaining)?$AfterBursts:$EmailsRemaining)*$RealWait) - (($AfterBursts>$EmailsRemaining)?0:($IntoBurst*$RealWait));
if ($TimeRemaining < ($EmailsRemaining*$RealWait) ) {
$TimeRemaining = $EmailsRemaining*$RealWait;
}
$CurIndex ++;
$LoopCount ++;
session_commit();
session_start();
$_SESSION[$EmailRef."_Index"] = $LoopCount;
$_SESSION[$EmailRef."_Remaining"] = round($TimeRemaining);
session_commit();
wa_sleep($WaitTime);
include("../webassist/email/waue_form_1.php");
$endtime = microtime_float();
$TimeTracker[] =$endtime - $starttime;
$RealWait = array_sum($TimeTracker)/sizeof($TimeTracker);
if ($LoopCount % $BurstSize == 0) {
$TimePassed = (time() - $StartBurst);
if ($TimePassed < ($BurstTime*60)) {
$WaitBurst = ($BurstTime*60) -$TimePassed;
wa_sleep($WaitBurst);
}
else {
$TimeRemaining = ($TotalEmails- $LoopCount)*$RealWait;
}
$StartBurst = time();
}
if (!$EnteredValue) {
$RecipArray[$RecipIndex][0] = mysql_fetch_assoc($RecipArray[$RecipIndex][1]);
}
}
$RecipIndex ++;
}
$_SESSION[$EmailRef."_Total"] = 0;
$_SESSION[$EmailRef."_Index"] = 0;
$_SESSION[$EmailRef."_Remaining"] = 0;
session_commit();
session_start();
if ($GoToPage!="") {
header("Location: ".$GoToPage);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="" method="post" enctype="multipart/form-data" name="form" id="form">
<p><label>Name
<input type="text" name="name" id="name" />
</label></p>

<p>
<label>
Upload
<input type="file" name="upload1" id="upload1" />
</p>

<p>
<input type="submit" name="submit" id="submit" value="Submit" />
</p>
</form>


</body>
</html>

Sign in to reply to this post

Jason ByrnesWebAssist

in the In the waue_for_1.php file try changing:

php:
//Attachment Entries

$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"".$WA_DFP_Uploa dStatus["WA_UploadResult1"]["serverFileName"] ."");



to:

php:
//Attachment Entries

$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverDirectory"]."".$WA_DFP_Uploa dStatus["WA_UploadResult1"]["serverFileName"] ."");
Sign in to reply to this post

jcrockett300688

That sends the image as an attachment - not the link.

I then tried wrapping your code with the href tag but it didn't work:

$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"<a href='http://www.mydomian.com/path/to/file/".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverDirectory"]."".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] . "'>" .$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] . "</a>");

Sign in to reply to this post

Jason ByrnesWebAssist

if you want it to be a link, then add the following in the email message:
<a href="http://www.mydomian.com/path/to/file/<?php echo $WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]; ?>"><?php echo $WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]; ?></a>

the meial message is created in the waue_for_1.php file.

Sign in to reply to this post

jcrockett300688

My bad...
I posted the wrong href wrap code - should have been:

$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"<a href=".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverDirectory"]."".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] . ">" .$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] . "</a>");

It still doesn't work...

Sign in to reply to this post

Jason ByrnesWebAssist

that href will not work, and the href should not be in the WAUE_AddAttachment function.


it will need to be in the email, and the correct href code is:



<a href="http://www.mydomian.com/path/to/file/<?php echo $WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]; ?>"><?php echo $WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]; ?></a>

Sign in to reply to this post

jcrockett300688

So... the missing piece of information seems to be that while you're creating the email in UE, you have to create a custom email to make this work. You can NOT use UE's prebuilt templates! (at least I could not get the templates to work with your code - after hours of trying).

Sign in to reply to this post

Jason ByrnesWebAssist

Hmmm, not sure why the file name is not available to the template page,


Here's a workaround for using the template though:


the code to upload the file is:

php:
<?php

WA_DFP_SetupUploadStatusStruct
("WA_UploadResult1") ;
if(
$_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult1""upload1""2""[NewFileName]_[Increment]""JPG:80"$WA_UploadResult1_Params);
}
?>





you can change that to store the file name in a session:

php:
<?php

WA_DFP_SetupUploadStatusStruct
("WA_UploadResult1") ;
if(
$_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult1""upload1""2""[NewFileName]_[Increment]""JPG:80"$WA_UploadResult1_Params);
$_SESSION['fileName'] = $WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"];
}
?>




then use the session in the link:

php:
<?php if(!session_id()) session_start(); ?>

<a href="http://www.mydomian.com/path/to/file/<?php echo $_SESSION['fileName'] ; ?>"><?php echo $_SESSION['fileName'] ; ?></a>
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...