473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

is there a possibility of getting rid of this error message?

anfetienne
424 256MB
Hi all,

this is real simple, I've written this code so I can duplicate images/files after uploading it with jumploader (this doesn't allow for duplicates during the upload process like standard upload handlers... sucks).

It does what it should do which is copy files from one directory to another but I get a error message "Warning: copy() [function.copy]: The first argument to copy() function cannot be a directory in /home/veresour/public_html/streammii.com/q/forTest.php on line 34"... is there a way to avoid this or atleast not display it?

Expand|Select|Wrap|Line Numbers
  1. $pathA = "user/aetienne/photos/aetienne853139394/tmp/l/";
  2. $pathB = "user/aetienne/photos/aetienne853139394/tmp/t/";
  3.  // path to the directory to read ( ./ reads the dir this file is in)
  4.     if ($handle = opendir($pathA)) {
  5.            while (false !== ($file = readdir($handle))) {
  6.         if ($file != "." && $file != "..") {
  7.             if(!is_dir($file)){
  8.                 $item[] = $file;
  9.                 sort($item,SORT_REGULAR);
  10.                 }
  11.                }
  12.            }
  13.            closedir($handle);
  14.     }
  15.         $total_items = count($item);
  16.  
  17.         print_r($item);
  18.  
  19.         echo '<br/>';
  20.  
  21.         $total_items = count($item);
  22.         echo $total_items;
  23.  
  24.         for($n=0; $n<=$total_items; $n++) {
  25.             $source = $pathA . $item[$n];
  26.             $destination = $pathB . $item[$n];
  27.             $thumbnailCopy = copy($source, $destination);
  28.         }
  29.  
Jul 9 '10 #1

✓ answered by zorgi

OK

Your problem is in line 24 "for loop" should look like this:

for($n=0; $n<=$total_items - 1; $n++) {

}

But it can be done without it:
Expand|Select|Wrap|Line Numbers
  1. $pathA = "user/aetienne/photos/aetienne853139394/tmp/l/";
  2. $pathB = "user/aetienne/photos/aetienne853139394/tmp/t/";
  3.  
  4. if($handle = opendir($pathA)) {
  5.     while (false !== ($file = readdir($handle))) {
  6.         if ($file != "." && $file != "..") {
  7.             if(!is_dir($file)){
  8.                 $destination = $pathB . $file;
  9.                 copy($file, $destination);
  10.             }
  11.         }
  12.     }
  13.     closedir($handle);
  14. }
  15.  

3 1384
zorgi
431 Expert 256MB
OK

Your problem is in line 24 "for loop" should look like this:

for($n=0; $n<=$total_items - 1; $n++) {

}

But it can be done without it:
Expand|Select|Wrap|Line Numbers
  1. $pathA = "user/aetienne/photos/aetienne853139394/tmp/l/";
  2. $pathB = "user/aetienne/photos/aetienne853139394/tmp/t/";
  3.  
  4. if($handle = opendir($pathA)) {
  5.     while (false !== ($file = readdir($handle))) {
  6.         if ($file != "." && $file != "..") {
  7.             if(!is_dir($file)){
  8.                 $destination = $pathB . $file;
  9.                 copy($file, $destination);
  10.             }
  11.         }
  12.     }
  13.     closedir($handle);
  14. }
  15.  
Jul 9 '10 #2
anfetienne
424 256MB
I never thought of it that way... thanks for the heads up zorgi it's much appreciated
Jul 10 '10 #3
anfetienne
424 256MB
ok thanks again zorgi for the idea here is my final code that I tested and it works perfectly... it duplicates the images then resizes them according to width and height

Expand|Select|Wrap|Line Numbers
  1. include('SimpleImage.php');
  2. $pathA = "user/aetienne/photos/aetienne919500405/tmp/l/";
  3. $pathB = "user/aetienne/photos/aetienne919500405/tmp/t/";
  4.  
  5.     if ($handle = opendir($pathA)) {
  6.            while (false !== ($file = readdir($handle))) {
  7.         if ($file != "." && $file != "..") {
  8.             if(!is_dir($file)){
  9.                 $source = $pathA . $file;
  10.                 $destination = $pathB . $file;
  11.                 copy($source, $destination);
  12.  
  13.  
  14.  $details = array();
  15.  $details = getimagesize($source);
  16.  $detailsWidth = $details[0];
  17.  $detailsHeight = $details[1];
  18.  
  19.              if ($detailsWidth > $detailsHeight){
  20.              $image = new SimpleImage();
  21.              $image->load("$source");
  22.              $image->resize(450,350);
  23.              $image->save("$source");
  24.  
  25.              $image = new SimpleImage();
  26.              $image->load("$destination");
  27.              $image->resize(100,70);
  28.              $image->save("$destination"); 
  29.              } 
  30.              elseif ($detailsHeight > $detailsWidth) {
  31.              $image = new SimpleImage();
  32.              $image->load("$source");
  33.              $image->resize(240,350);
  34.              $image->save("$source"); 
  35.  
  36.              $image = new SimpleImage();
  37.              $image->load("$destination");
  38.              $image->resize(70,100);
  39.              $image->save("$destination"); 
  40.              }
  41.                 }
  42.                }
  43.            }
  44.            closedir($handle);
  45.     }
  46.  
Jul 10 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Philip Ronan | last post by:
OK, here's my 2p worth: === Q. Why am I getting the error message 'Headers already sent'? A. PHP produces this error message when you try to set a header for a web page after you have already...
1
by: Dan | last post by:
I can't figure out this error message. Could someone please help. I have a text file in Notepad with the following 4 fields (Cont, Code, List, and Numb)all of which are single tab delimited, and a...
6
by: Bill English | last post by:
Go here: http://68.81.193.200/error.bm I don't understand why I would be getting this error. I will be glad to answer any questions.
1
by: mar-kav | last post by:
Hello, i'm a beginner so exuse me: i installed IIS 5.1, Framework1.1, vs .NET 2003 i put my web dir' in inetpub/wwwroot, tried to broows to my homepage under localhost & got this error message: ...
1
by: riyaz | last post by:
"An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately." i am...
2
by: amita | last post by:
when i am writing a program in c# using windows app I am getting this error message as System.Windows.Forms.Control.Text is inaccessable due to its protection level. In the design window when i...
4
by: ramesh nambiar reloaded | last post by:
#include<stdio.h> #include<string.h> #include<conio.h> #include<dos.h> // #include<object.h> const char *hex = "0123456789ABCDEF"; char *bin2hex(char *string); int...
5
by: Horhay5150 | last post by:
I am admittedly a noob to PHP and mySQL, Have been running through some tutorials. Whenever I run the following script I get this error message: mysql_query() expects parameter 2 to be resource,...
5
by: hpailles | last post by:
I keep getting this error, could somebody help? <?php if ((!$_POST) || (isset($_GET)){ //haven't seen the form, so show it $display_block = " <form method=\"post\"...
5
AAPWM
by: AAPWM | last post by:
Hello My job is to extract data from my companies database with Crystal Reports, export that data to Excel, modify the data, save the data as "Text "tab delimited"", and upload to the database...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.