473,407 Members | 2,598 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,407 software developers and data experts.

copying, renaming and then moving images

anfetienne
424 256MB
Hi, basically what i have got is a upload form that im linking to a flash gallery. The gallery uses two versions of an image....1 is for the thumbnail and the other the actual image. When i upload the images I am able to copy the files into a temp folder.

What id like to do now is resize the images, rename them and then move them back to the original folder.....can someone tell me where i can get started with this?

thanks in advance
Mar 3 '09 #1
4 2116
Markus
6,050 Expert 4TB
The GD image manipulation tools are really useful for this stuff!
Mar 3 '09 #2
anfetienne
424 256MB
im a noob with php....i dont understand a thing about libraries yet lol....could you suggest something just using php? i can understand it once i see it and do what i need need to get it to do but i dont know anything about the structures and variables best to do so
Mar 3 '09 #3
Markus
6,050 Expert 4TB
To use image manipulation functions, you're going to need one of the libraries (GD or ImageMagick.. I'm sure there are others too).

To copy (and rename a file) have a look at Copy().
Mar 5 '09 #4
anfetienne
424 256MB
i have already got the files to copy from the original folder to a temp folder...then renamed them as i need them i.e.

1b.jpg
2b.jpg
3b.jpg etc

its just copying them back thats the problem

this is my code for the whole file that im working on:

Expand|Select|Wrap|Line Numbers
  1. <!doctype html public "-//w3c//dtd html 3.2//en">
  2. <html>
  3. <head>
  4. <title>Multiple image upload script from plus2net.com</title>
  5. </head>
  6. <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
  7. <?
  8.  
  9. $random_digit = $_POST['ID'];
  10. $returnURL = $_POST['returnURL'];
  11.  
  12. $imgtemp=mkdir("upload/imgtemp/$random_digit", 0777); 
  13.  
  14.  
  15. ?>
  16.  
  17.  
  18.  
  19. <?
  20. while(list($key,$value) = each($_FILES['images']['name']))
  21.         {
  22.             if(!empty($value))
  23.             {
  24.                 $filename = $value;
  25.                     $filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
  26.  
  27.                     $add = "upload/$random_digit/$filename";
  28.                     $tempFLDR = "upload/imgtemp/$random_digit/$filename";
  29.                        //echo $_FILES['images']['type'][$key];
  30.                  // echo "<br>";
  31.                     copy($_FILES['images']['tmp_name'][$key], $add);
  32.                     chmod("$add",0777);
  33.                     copy($_FILES['images']['tmp_name'][$key], $tempFLDR);
  34.                     chmod("$tempFLDR",0777);
  35.  
  36. $folderPath="upload/$random_digit/";
  37.             }
  38.         }
  39. ?>
  40.  
  41. <?
  42. //fill in details about the path
  43. $path="upload/$random_digit/";
  44.  
  45. //variable used for the name of each file
  46. $i=1;
  47.  
  48. $od = opendir($path);
  49. while (false !== ($filename = readdir($od)))
  50. {
  51.     //you can add any type of filenames you wish to skip (for instance Thumbs.db on windows)
  52.     if($filename != '.' && $filename != '..' && !is_dir($path.$filename))
  53.     {
  54.         //we give files a name - here we use increasing numbers for jpg files:
  55.         if(rename($path.$filename, $path.$i++.'.jpg'))
  56.         echo 'Renamed file '.$filename.'<br />';
  57.     }
  58. }
  59.  
  60. closedir($od);
  61.  
  62. ?>
  63.  
  64. <?
  65. //fill in details about the path
  66. $pathT="upload/imgtemp/$random_digit/";
  67.  
  68. //variable used for the name of each file
  69. $i=1;
  70.  
  71. $odT = opendir($pathT);
  72. while (false !== ($filename = readdir($odT)))
  73. {
  74.     //you can add any type of filenames you wish to skip (for instance Thumbs.db on windows)
  75.     if($filename != '.' && $filename != '..' && !is_dir($pathT.$filename))
  76.     {
  77.         //we give files a name - here we use increasing numbers for jpg files:
  78.         if(rename($pathT.$filename, $pathT.$i++.'b.jpg'))
  79.         echo 'Renamed file '.$filename.'<br />';
  80.     }
  81. }
  82. closedir($odT);
  83. ?>
  84.  
  85. <?
  86. copy($tempFLDR, $path) or die ;
  87. ?>
  88. <?
  89. $username="vecre0_tempU";
  90. $password="auction";
  91. $database="vecre0_templates";
  92.  
  93.  
  94. // OPEN CONNECTION ---> 
  95. $connection=mysql_connect("localhost","$username", "$password") or die("Unable to connect!");
  96.  
  97. mysql_select_db("$database") or die("Unable to select database!");
  98.  
  99.  
  100. //  EXECUTE QUERY ---> 
  101. $query="INSERT INTO paths (
  102.  
  103.             folderPath)
  104.  
  105.         VALUES(        
  106.             '".$folderPath."')";
  107. //////-----> 
  108. $result=mysql_query($query) or die("Error in query:".mysql_error()); 
  109. //if ($result) 
  110.     //echo mysql_affected_rows()." row inserted into the database effectively."; 
  111.  
  112. //  CLOSE CONNECTION ---> 
  113. mysql_close($connection); 
  114. ?>
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121. </body>
  122.  
  123. </html>
  124.  
Mar 5 '09 #5

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

Similar topics

1
by: Sarah | last post by:
Hi, Can someone please tell me if there's a way to copy image files from one server to another using ASP and FSO? Or perhaps some other way to do it? I'm trying to collect information on...
22
by: Matt | last post by:
When browsing a web page a user has the ability to highlight content on a page (by holding down the left mouse button and dragging the mouse over the desired content). Is there a way to disable...
0
by: Kirk | last post by:
I have created an application that copies images I select to two printer que's. The images are either AutoCAD plot files (.PLT) or scanned images (.TIF). My method works well for the PLT files on...
3
by: Daves | last post by:
why the heck can't I use Directory.Move() to rename a directory (containing files) to a entry 2 levels below e.g. uploads/tempfiles -> uploads/tempfiles/48/003files if I do this in one line...
48
by: mantrid | last post by:
Hello Is there a way to prevent users copying a full size image from a web page. Displaying the image with a smaller width and height only affects the image as viewed, the actual full size image...
6
by: Neil | last post by:
I have a form that has its own custom menu bar in Access 2000. I'd like to make a copy of the menu bar and use it with another form. How can I do this? Thanks.
1
by: rush81 | last post by:
i'm trying to create an ssis package for renaming and moving the file. It gives error at the file system task: Error: An error occurred with the following error message: "Could not find file...
2
by: chazzy69 | last post by:
This is a little hard to explain but i will try to make it as clear as possible. Firstly here's the setup, 2 databases on 2 different servers (databases are identical) now within the first...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.