Sabtu, 16 November 2013

PHP Indonesia - Facebook: [ASK| How to upload a photo with php ?] master mau...

PHP Indonesia - Facebook
PHP Indonesia is a community for everyone that loves PHP. Our focus is in the PHP world but our topics encompass the entire LAMP stack. Topics include PHP coding, to memcached handling, db optimizations, server stack, web server tuning, code deploying, hosting options and much much more. Youtube Channel : http://www.youtube.com/user/OurPHPIndonesia Twitter : @php_indonesia NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
Learn to Code Websites

in 10 weeks with a part time course. Learn html, css and javascript from the best instructors. Apply now!
From our sponsors
[ASK| How to upload a photo with php ?] master mau...
Nov 16th 2013, 15:00, by Fitrie Utrie

Fitrie Utrie 3:00pm Nov 16
[ASK| How to upload a photo with php ?]
master mau nanya, proses upload foto yang mudah gimna dan scriptnya mudah dipahami ?
udah beberpa kali saya buat, tapi belum berhasil

trims :)

Batara Parada Siahaan 3:19pm Nov 16
view.php

<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="myFile">
<br>
<input type="submit" value="Upload">
</form>

Batara Parada Siahaan 3:19pm Nov 16
process.php

define("UPLOAD_DIR", "/folder direktori dimana file ingin disimpan");

if (!empty($_FILES["myFile"])) {
$myFile = $_FILES["myFile"];

if ($myFile["error"] !== UPLOAD_ERR_OK) {
echo "<p>An error occurred.</p>";
exit;
}

// ensure a safe filename
$name = preg_replace("/[^A-Z0-9._-]/i", "_", $myFile["name"]);

// don't overwrite an existing file
$i = 0;
$parts = pathinfo($name);
while (file_exists(UPLOAD_DIR . $name)) {
$i++;
$name = $parts["filename"] . "-" . $i . "." . $parts["extension"];
}

// preserve file from temporary directory
$success = move_uploaded_file($myFile["tmp_name"],
UPLOAD_DIR . $name);
if (!$success) {
echo "<p>Unable to save file.</p>";
exit;
}

// set proper permissions on the new file
chmod(UPLOAD_DIR . $name, 0644);
}

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions

Tidak ada komentar:

Posting Komentar