PHP $upload_dir Error!!!!!
Posted: Thu Oct 26, 2006 3:20 pm
feyd | Please use
Also here is an Illustration of what i need to do:

So if some one can please help me with htis it would be great.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi. My name is Zain. I am having problem with this PHP code i recently used. this code is supposed to upload a file and put it in a directory in the server. Now i want to upload this fil from the server my PHP file is on and upload it to another server or save it in another server. here is the code:Code: Select all
<?php
//edit this
$_max_file_size = '9999999999'; //file size in bytes.
$upload_dir = "Gallery/"; //upload folder..chmod to 777
$_i = "8"; //number of files to upload at one time
//end edit
echo "Maximum file size : " . $_max_file_size/1000 . "KB<br>";
echo "<form enctype='multipart/form-data' action='?do=upload' method='post'>";
echo "<input type='hidden' name='MAX_FILE_SIZE' value='" . $_max_file_size , "'>";
echo "Choose your file(s): <br>";
//show number of files to select
For($i=0; $i <= $_i-1;$i++)
{
echo "<input name='file" . $i . "' type='file'><br>";
}
echo "<input type='submit' value='Upload File'>";
echo "</form>";
if($_GET['do'] == 'upload')
{
//upload all the fields until done
For($i=0; $i <= $_i-1; $i++)
{
//create a random number
$_random = rand(1, 1000000);
//file with the upload folder
$target_path = $upload_dir . $_random . basename($_FILES['file' . $i]['name']);
//actual file name with the random number
$_file_name = $_random . basename($_FILES['file' . $i]['name']);
//do not upload the 'left blank' fields
if(basename($_FILES['file' . $i]['name']) != '')
{
if(move_uploaded_file($_FILES['file' . $i]['tmp_name'], $target_path))
{
//uploaded successfuly
$_uploaded=1;
}
else
{
//error uploading
$_error=1;
}
}
else
{
$_check=$_check+1;
}
}
//file(s) did upload
if($_uploaded == '1')
{
$_uploaded=0;
echo "The file(s) have been uploaded.<br>";
}
//file uploaded?
if($_error == '1')
{
$_error=0;
echo "There was an error uploading some of the file(s), please try again! Maybe the file size. Maximum file size is " . $_max_file_size/1000 . "KB<br>";
}
//user selected a file?
if($_check == $_i)
{
$_check=0;
echo "Select a file first than click 'Upload File'<br>";
}
}
?>Also here is an Illustration of what i need to do:
So if some one can please help me with htis it would be great.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]