Jump to content
php.lv forumi

Upload scripts.


Slawe

Recommended Posts

Izveidojam direktoriju, manā gadījumā Files! Tad uzcepam HTML formu, kur varam uploadot:

<html>

<head>

<title>File Upload</title>

</head>

<body>

<form enctype="multipart/form-data" action="uploader.php" method="POST">

<input type="hidden" name="MAX_FILE_SIZE" value="100000" />

Izvēlies failu, kuru uploadot: <input name="uploadedfile" type="file" /><br />

<input type="submit" value="Upload File" />

</form>

</body>

</html>

 

Tagad uzcepam PHP scriptu:

<?php

$target_path = "Files/";

$target_path = $target_path.$_FILES['uploadedfile']['name'];

 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {

echo "Fails ". $_FILES['uploadedfile']['name']." ir uploadots";

} else {

echo "Kaut, kas nesanāca!";

}

?>

Link to comment
Share on other sites

×
×
  • Create New...