473,547 Members | 2,416 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

424 Contributor
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);
  17.         print_r($item);
  19.         echo '<br/>';
  21.         $total_items = count($item);
  22.         echo $total_items;
  24.         for($n=0; $n<=$total_items; $n++) {
  25.             $source = $pathA . $item[$n];
  26.             $destination = $pathB . $item[$n];
  27.             $thumbnailCopy = copy($source, $destination);
  28.         }
Jul 9 '10 #1
3 1390
431 Recognized Expert Contributor

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/";
  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. }
Jul 9 '10 #2
424 Contributor
I never thought of it that way... thanks for the heads up zorgi it's much appreciated
Jul 10 '10 #3
424 Contributor
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/";
  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);
  14.  $details = array();
  15.  $details = getimagesize($source);
  16.  $detailsWidth = $details[0];
  17.  $detailsHeight = $details[1];
  19.              if ($detailsWidth > $detailsHeight){
  20.              $image = new SimpleImage();
  21.              $image->load("$source");
  22.              $image->resize(450,350);
  23.              $image->save("$source");
  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"); 
  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.     }
Jul 10 '10 #4

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

Similar topics

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 started sending out the content of the page. Web content is always delivered with a few headers at the top, ending with a blank line. For...
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 bunch of rows with values. I tried to create a macro (with the TransferText action) that would automatically import the values from those fields...
by: Bill English | last post by:
Go here: I don't understand why I would be getting this error. I will be glad to answer any questions.
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: Server Error in '/' Application. -------------------------------------------------------------------------------- Configuration Error...
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 getting this error for the form authentication page. regards Niaz
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 am placing some controls like textbox,label and button.---my code the code displayed is as follows public class form1:system.windows.forms.form...
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 binstring2number(char *string);
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, boolean given. Any help would be greatly appreciated. <?php $input = $_POST;
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\" action=\"".$_SERVER."\">
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 once again. Ive done this for close to a year and have never had this error message. "Error converting data type varchar to numeric" 2255;2801...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.