Pure PHP Upload 2 Support Product Page

Solved

Pure PHP Upload with Advanced Multi Uploader NOT creating dynamic folders

Reported 20 Nov 2012 13:47:40
2
have this problem
20 Nov 2012 13:47:40 David Woolley posted:
I'm using Pure PHP Upload with Advanced Multi Uploader, and having trouble uploading images to dynamic variable folders. Each subfolder should be created according to a session variable, so path statement in PPU server behavior is:

path = "images/case_images/".$_SESSION['AccessionNo'];

The images are all being uploaded to path "images/case_images/" and the variable subfolder is not being created.

Does this work if using PPU with the Multi-Uploader?

I also have 2 instances of Smart Image Processor PHP - one for the large images & the other for the thumbs. Everything works except for the variable folder.

Replies

Replied 20 Nov 2012 14:15:43
20 Nov 2012 14:15:43 Teodor Kuduschiev replied:
Hello David,

I am using the same method to create dynamic folders and have no problems with that.
Did you make sure the SESSION is created when the upload starts?
Replied 20 Nov 2012 14:37:33
20 Nov 2012 14:37:33 David Woolley replied:
Thanks for the quick reply.
I echoed the session at the top of the page before the upload.

I also checked with a recordset binding after moving the PPU SB code block below the recordset, like so:

path = "images/case_images/".$row_rsCase['accession_no'];

Still did not work, but not sure if that's feasible.

Cheers
David
Replied 20 Nov 2012 14:57:01
20 Nov 2012 14:57:01 Teodor Kuduschiev replied:
Can you please check the permissions to create folders/files in this folder?
can you also provide a link to your page: my email is
Replied 20 Nov 2012 15:24:52
20 Nov 2012 15:24:52 David Woolley replied:
I'll check the create permissions. I'm still on a local testing server using XAMPP, so I can't really give you a link to the page. Get back to you soon.
Replied 21 Nov 2012 10:35:13
21 Nov 2012 10:35:13 David Woolley replied:
It does not seem to be a permissions problem. I tried giving the /images/case_images/ folder full control for Users but still no luck. Changed back to default permissions for Users

I changed the path in PPU where 'testsubfolder' does not exist yet.

path = "images/case_images/testsubfolder/"

This works fine - creates the folder, then uploads the images to this new folder.

But still does not work with a variable.

Should I send you the page code?
Replied 21 Nov 2012 11:12:12
21 Nov 2012 11:12:12 Teodor Kuduschiev replied:
Please send it to my email:
Replied 21 Nov 2012 12:15:53
21 Nov 2012 12:15:53 Teodor Kuduschiev replied:
Hello,

Can you please try setting the session variable in your code like:

<?php $_SESSION['AccessionNo'] = 1234; ?>



And see if a folder named "1234" gets created?
Replied 21 Nov 2012 12:36:41
21 Nov 2012 12:36:41 David Woolley replied:
That works! Images stored in new folder 1234
Getting there.
Replied 21 Nov 2012 13:01:10
21 Nov 2012 13:01:10 Teodor Kuduschiev replied:
Then it seems to me your session does not take its name properly.
Replied 21 Nov 2012 15:20:50
21 Nov 2012 15:20:50 David Woolley replied:
But the session is displayed properly when echoed on the page before the form. Any other ways of testing?
Replied 21 Nov 2012 16:30:52
21 Nov 2012 16:30:52 Teodor Kuduschiev replied:
Hello,

Please make sure the Recordset Code is Before:


<?php session_start();?>
<?php $_SESSION['AccessionNo']=$row_Recordset1['name'] ?>

Replied 28 Nov 2012 09:06:52
28 Nov 2012 09:06:52 David Woolley replied:
I've tried this using PPU & SIPP2 without using the Adv Multi Uploader, and all works perfectly.

New folder created dynamically from the session like so:

$ppu->path = "images/case_images/".$_SESSION['AccessionNo'];

Large images & thumbs created in this new folder.(2 instances of SIPP2)

The image filename is created in the 'sp_images' table that has a many-to-one relationship with the 'cases' table. There will be several images attached to a case, so ideally I would like to use the AMU for this.

----------------------------------------------------

Back to the page with AMU:

The DW Insert Record SB lists 2 fields: Filename & Filedata that can be bound. What is the Filedata used for? Is that info from the AMU advanced tab?

I also have added 2 hidden fields to the multi-uploader form where values are inserted into the 'sp_images' table from 2 session variables from the linking page:

<input name="case_id" type="hidden" id="case_id" value="<?php echo $_SESSION['WA_add_case']; ?>" />
<input name="imgpath" type="hidden" id="imgpath" value="<?php echo $_SESSION['AccessionNo']; ?>" />

'sp_images' table has 3 fields:

img_id (primary key)
case_id (foreign key)
imgpath (stores folder name)


Any more ideas on why the multi-uploader can't read a session variable or a dynamic binding from the recordset. Is there an issue with this?
As I said it works fine without the AMU.

Cheers
Dave
Replied 04 Dec 2012 10:06:41
04 Dec 2012 10:06:41 David Woolley replied:
Any suggestions Teodor?
Replied 04 Dec 2012 10:46:25
04 Dec 2012 10:46:25 Teodor Kuduschiev replied:
Hi David,

As i told you in my previous post:
Please make sure the Recordset Code is Before:


<?php session_start();?>
<?php $_SESSION['AccessionNo']=$row_Recordset1['name'] ?>
About the:
The DW Insert Record SB lists 2 fields: Filename & Filedata that can be bound.

The filename hols the uploaded files names and the filedata can be used to save the width/height.
Replied 04 Dec 2012 11:24:19
04 Dec 2012 11:24:19 David Woolley replied:
Nope that does not work - I tried that already, before comparing the method with and without AMU. No problem without the AMU - session variable from a previous page is used correctly by path in PPU.
Replied 04 Dec 2012 15:27:58
04 Dec 2012 15:27:58 Teodor Kuduschiev replied:
Hello David,

I just tested the following page and the folder defined in the session variable is being created.



<?php require_once('ScriptLibrary/incPureUpload.php'); ?>
<?php session_start(); 
$_SESSION['folder']='Teodor';

?>
<?php
// Pure PHP Upload 2.1.12
$ppu = new pureFileUpload();
$ppu->path = "img/". $_SESSION['folder'];;
$ppu->extensions = "";
$ppu->formName = "UploadQueue";
$ppu->storeType = "file";
$ppu->sizeLimit = "";
$ppu->nameConflict = "over";
$ppu->nameToLower = false;
$ppu->requireUpload = true;
$ppu->minWidth = "";
$ppu->minHeight = "";
$ppu->maxWidth = "";
$ppu->maxHeight = "";
$ppu->saveWidth = "";
$ppu->saveHeight = "";
$ppu->timeout = "600";
$ppu->progressBar = "";
$ppu->progressWidth = "300";
$ppu->progressHeight = "100";
$ppu->redirectURL = "";
$ppu->checkVersion("2.1.12");
$ppu->doUpload();

if (isset($editFormAction)) {
  if (isset($_SERVER['QUERY_STRING'])) {
	  if (!eregi("GP_upload=true", $_SERVER['QUERY_STRING'])) {
  	  $editFormAction .= "&GP_upload=true";
		}
  } else {
    $editFormAction .= "?GP_upload=true";
  }
}
?>
<!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>
<script language='javascript' src='ScriptLibrary/incPureUpload.js' type="text/javascript"></script>
<script language='javascript' src='ScriptLibrary/incPureUpload.js' type="text/javascript"></script>
</head>

<body>
<?php
//retrieve session data
echo "Folder=". $_SESSION['folder'];
?>
<form action="<?php echo $GP_uploadAction; ?>" method="post" enctype="multipart/form-data" name="UploadQueue" id="UploadQueue" onsubmit="checkFileUpload(this,'',true,'','','','','','','');return document.MM_returnValue">
  <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,63,0" width="550" height="350" id="upload1" align="middle">
    <param name="FlashVars" value="url=<?php echo urlencode($GP_uploadAction); ?>&formName=UploadQueue&FlashUpload=true<?php if ($ppu->redirectURL <> '') {echo "&redirectUrl=".$ppu->redirectURL;}?>" />
    <param name="movie" value="dmxMultiUploader.swf" />
    <param name="quality" value="best" />
    <param name="wmode" value="transparent" />
    <!--[if !IE]>-->
    <embed src="dmxMultiUploader.swf" name="upload1" quality="best" flashvars="url=<?php echo urlencode($GP_uploadAction); ?>&formName=UploadQueue&FlashUpload=true<?php if ($ppu->redirectURL <> '') {echo "&redirectUrl=".$ppu->redirectURL;}?>" wmode="transparent" type="application/x-shockwave-flash" width="550" height="350" pluginspage="http://www.macromedia.com/go/getflashplayer" />
    <!--<![endif]-->
  </object>
  <input name="Filename" type="file" style="display:none" onchange="checkOneFileUpload(this,'',true,'','','','','','','')" />
  <input type="hidden" name="Filedata" />
  <script type="text/javascript">window.upload1 = document.forms["UploadQueue"].upload1;</script>
</form>
</body>
</html>


Replied 04 Dec 2012 15:55:27
04 Dec 2012 15:55:27 Teodor Kuduschiev replied:
I think i found the problem. I created a page that holds my recordset and there i create a session variable = recordset value. On another page i call the session variable and after that do the upload.

In Firefox it seems to be some sort of caching with the flash and it does not change the upload folder when the session variable value changes.

In chrome this is not an issue. I will check what exactly goes wrong with flash caching and Firefox.
Replied 05 Dec 2012 07:47:04
05 Dec 2012 07:47:04 David Woolley replied:
Aah - my setup works perfectly with Chrome and IE8 & 9. I'll wait for the Firefox fix. Almost there!

Thanks a lot
Dave
Replied 07 Jan 2013 09:09:54
07 Jan 2013 09:09:54 David Woolley replied:
Any news on the Firefox flash caching issue with Advanced Multi-Uploader?

Cheers
Dave
Replied 16 Aug 2013 13:36:24
16 Aug 2013 13:36:24 David Woolley replied:
Still enquiring about the Firefox flash caching issue with Advanced Multi-Uploader using dynamically created folders.

I tried putting some cache-control http response headers at line 1 of the PHP file, but still no luck with Firefox.


<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
?>


oops just realized this is not going to affect the flash cache!
Replied 20 Aug 2013 11:21:19
20 Aug 2013 11:21:19 David Woolley replied:
Just updated AMU to latest version 1.0.5 that is compatible with PPU3.
Now upgraded to PPU3 on this page. Everything works fine in IE 8 9 10 & Chrome but same problem with Firefox & Safari (Win7) not uploading to dynamic folder.

I'm using 3 instances of SIPP2 for 3 different image sizes, but Safari uploads the original image only (no resizing)

Cheers
Dave

Reply to this topic