This topic is locked

Upload Folder Variables?

2/11/2010 11:53:38 AM
PHPRunner General questions
K
Khris author

I've got a few tables setup with a File/Image upload VarChar field, however I'm wondering if it's possible to arrange uploads by year and month instead of all going into the same folder as defined in the "Edit As" settings.
Is this even possible with PHPRunner?

Sergey Kornilov admin 2/11/2010

This can be done. Here is the example that can get you started:

http://xlinesoft.com/phprunner/docs/upload_files_to_users_folders.htm

K
Khris author 2/12/2010



This can be done. Here is the example that can get you started:

http://xlinesoft.com/phprunner/docs/upload_files_to_users_folders.htm


First of all, I'm a little unsure of which event this code should be placed in? Global event? Before record added? After record added?
Second, I've changed it to the following which I think will put things in a YEAR/MONTH folder structure.

//Upload all files into Year/Month folders
global $files_move;
foreach( $files_move as $key=>$val)
{
if($val[0]==$_FILES["file_Attachment"]["tmp_name"])
$files_move[$key][1] = date("Y")."/".date("m")."/".$values["ID"];
}
$values["Attachment"] = $values["ID"];
J
Jane 2/15/2010

Hi,
add this code to theBefore record added event.

K
Khris author 2/19/2010

I've changed my code to this, but I'm getting the following error after it.

//Upload all files into Year/Month folders
global $files_move;
foreach( $files_move as $key=>$val)
{
if($val[0]==$_FILES["file_Attachment"]["tmp_name"])
$files_move[$key][1] = "files/PackingSlips/".date("Y")."/".date("m")."/".$values["ID"];
}
$values["Attachment"] = $values["ID"];
return true


Technical information

Error type 2

Error description move_uploaded_file(C:\Inetpub\wwwroot\PSS/files/PackingSlips/2010/02/) [function.move-uploaded-file]: failed to open stream: No such file or directory

URL edmapps1.XXXXXXXXXXXXXXXX.com/pss/pss_packingslips_add.php?

Error file C:\Inetpub\wwwroot\PSS\include\phpfunctions.php

Error line 641

SQL query insert into pss_packingslips (PO Number, Job Number, Vendor, Date Received, City, Notes, Attachment, Email, Email Address, Entered By, Date Entered) values (9999, null, 'Memory Express', '2010-02-19 00:00:00', 'Edmonton', '', '', 0, '', 'cphillips', '2010-02-19 14:55:40')

Solution It seems that you type incorrect path to subfolder where files reside. The path should be relative to the folder for generated pages. Type upload/ in the Folder where files reside box on the "Edit as settings" dialog on the "Visual Editor" Tab.