upload pics from predifined list of files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adi5402
Forum Newbie
Posts: 10
Joined: Mon Jun 23, 2008 2:27 pm

upload pics from predifined list of files

Post by adi5402 »

Hi Guys I want to upload a picture to a perticular folder using a predefined list of files.

In my first attempt i made a form that looks like this

Code: Select all

<form id="Upload" action="changeImage.php" enctype="multipart/form-data" method="post">
	
		<h1>
			Upload form
		</h1>
		
		<p>
			<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size ?>">
		</p>
		
		<p>
			<label for="file1">Apply Add:</label>
            
            <select name="newImage" type="file">
            
            <option value="C:\xampp\webalizer\TEST\RateList\Images\B2Blogo.jpg"> B2bLogo</option>
            <option value="C:\xampp\webalizer\TEST\RateList\Images\piecesOnly.jpg" > PiecesOnly </option>
            <option value="C:\xampp\webalizer\TEST\RateList\Images\packageingStyrofoam.jpg" > Packageing Styrofoam </option>
            
            </select>
            
            
	
				
		<p>
			<label for="submit">Press to...</label>
			<input id="submit" type="submit" name="submit" value="Change Image">
		</p>
	
	</form>



One way of working this out was to have this form submit and populate another form with an input field that is hidden and forwards the image request

Code: Select all

// Form 2 
$newImage = $_POST['newImage'];

<form id="Upload" action="echo $uploadHandler" enctype="multipart/form-data" method="post">
	
		<h1>
			Upload form
		</h1>
		
		<p>
			<input type="hidden" name="MAX_FILE_SIZE" value="$max_file_size">
		</p>
		
		<p>
			<label for="file1">File to upload:</label>
			<input  id="file1" type="file" name="file[]"  value="<?php echo $newAdd ?>" style='visability:hidden;' >
		</p>

THEN SUMBIT THIS TO AN PHP PROCESS UPLOAD PAGE THAT TAKES THE REQUEST AND UPLOADS THE FILE.

can some on help me on this
I am really stuck here.

THANKS IN ADVANCE
adi5402
Forum Newbie
Posts: 10
Joined: Mon Jun 23, 2008 2:27 pm

Re: upload pics from predifined list of files

Post by adi5402 »

I solved the problem using the following code

Code: Select all



<?php
//$thisdir = getcwd(); // dont need this for localhost

// This is the file we want to transfer
$file = 'newImage/STC2033375M1.01.jpg';

//$file =$thisdir.$file;
// this is wher we want to store it
$newfile = 'images/TargetImage.jpg';





if (!copy($file, $newfile)) {
    echo "failed to copy $file...\n";
}
?>


Post Reply