472,371 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 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 1342
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: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

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.