moving pictures

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I am using this code to move one picture to my server.
Part of the code:
if ($pic_size > 0) {
            mkdir("$dir/$date", 0777);
           $upload_file = system("/bin/cp $pic $dir/$date/big$fname", $retval);
           $convert = system("convert -scale 320x240 $pic
$dir/$date/small$fname", $ret);
           $convert = system("convert -scale 160x120 $pic
$dir/$date/thumbnail$fname", $ret);

            if ($retval==0) {

The $pic I take from the form.
How can I move whole folder instead of one file?


Re: moving pictures

Well, you seem to be doing everything with system calls instead of PHP
functions.  So you can use some system call to move an entire folder,
or you can use the PHP directory functions:

You can use opendir to open the directory, and readdir to scan through
each file.  See the documentation for readdir.  Make sure to use is_dir
to check if the file is a file or a directory before moving it (you
probably only want to move files).  Then you can use copy to copy each
file you find.  If you want to move instead of copy, just use unlink to
delete each source file after the copy.


Site Timeline