Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Upload - pomoc przy skrypcie, Jeden mały szczegół
Rafael6666
post
Post #1





Grupa: Zarejestrowani
Postów: 95
Pomógł: 0
Dołączył: 20.10.2006

Ostrzeżenie: (10%)
X----


Chciałbym, aby w moim hostingu plików, po kliknięciu przycisku "Upload System" pokazywał się obrazek , jako ładowanie pliku, a kiedy plik zostanie załadowany, ma pokazać się adres url pliku. Narazie udało mi się osiągnąć coś takiego http://uploadsystem.go.pl.

Kod skryptu:
Kod
<center><?php
//edit this
$_max_file_size = '1000000'; //file size in bytes.
$upload_dir = "upload/"; //upload folder..chmod to 777
$_i = "1";                //number of files to upload at one time
//end edit

echo "";
echo "<form enctype='multipart/form-data' action='?do=upload' method='post'>";
echo "<input type='hidden' name='MAX_FILE_SIZE' value='" . $_max_file_size , "'>";
echo "";
//show number of files to select
For($i=0; $i <= $_i-1;$i++)
{
echo "<input name='file" . $i . "' type='file'size='25'>";
}
echo "<input type='submit' value='Upload System'><br>";
"</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
$_file_name = $_random . basename($_FILES['file' . $i]['name']);
$tab = explode('.', $_file_name);
$nazwa = $tab[count($tab)-1];
$target_path = ("$upload_dir$_random.$nazwa");
//actual file name with the random number

//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 "<input type='text'value='http://rufus.ifastnet.com/upload/$_random.$nazwa'size='60'>";
}
//file uploaded?
if($_error == '1')
{
$_error=0;
echo "";
}
//user selected a file?
if($_check == $_i)
{
$_check=0;
echo "";
}
}
?></center>


--------------------
Kompleksowe i profesjonalne tworzenie stron www
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 13:39