Markie
Posts: 251
|
| Posted: 12/03/2008, 4:13 AM |
|
I have a little problem moving an uploaded photo from one album to another. I have made a page where users can move a photo to a different album (editable grid). I have a listbox, showing all possible albums. The name of this listbox is "album"
In my grid there's also a hidden field showing the "old" albumname. The name of this hidden field is album2.
The name of the photo is in a text field, named "Basename"
I have made a AfterSubmit custom code in my editable grid:
$newalbumname = $Container->album->GetValue();
$Basename = $Container->Basename->GetValue();
$albumname = $Container->album2->GetValue();
define ("DIRECTORY", "$albumname");
do {
$dir = DIRECTORY;
while (!is_dir($dir)) {
$basedir = dirname($dir);
if ($basedir == '/' || is_dir($basedir))
mkdir($dir,1777);
else
$dir=$basedir;
}
} while ($dir != DIRECTORY);
rename("$albumname/".$Basename,"$newalbumname/".$Basename);
The output of my web page is:
Warning: rename(1stalbum/1stphoto.jpg,2ndalbum/1stphoto.jpg) [function.rename]: No such file or directory in C:\xampp\htdocs\mysite\edit_photos_events.php on line 166
Warning: Cannot modify header information - headers already sent by etc. etc.
So, there's something wrong with my code ...
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL |
 |
 |
Markie
Posts: 251
|
| Posted: 12/03/2008, 5:08 AM |
|
I think I have solved my problem myself, I used $container instead of $component. Now it works, with this code:
$newalbumname = $Component->album->GetValue();
$Basename = $Component->Basename->GetValue();
$albumname = $Component->album2->GetValue();
define ("DIRECTORY", "$albumname");
do {
$dir = DIRECTORY;
while (!is_dir($dir)) {
$basedir = dirname($dir);
if ($basedir == '/' || is_dir($basedir))
mkdir($dir,1777);
else
$dir=$basedir;
}
} while ($dir != DIRECTORY);
rename("$albumname/".$Basename,"$newalbumname/".$Basename);
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL |
 |
 |
|