Upload image
unknown
php
5 years ago
962 B
9
Indexable
$image_name=basename($_FILES["p_img"]["name"]);
$alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
$pass = ''; //remember to declare $pass as an array
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
for ($i = 0; $i < 15; $i++) {
$n = rand(0, $alphaLength);
$pass = $pass . $alphabet[$n];
}
$passtype=$pass;
$target_dir = public_url("uploads/product/");
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
$target_file = $target_dir . basename($passtype);
$uploadOk = 1;
if (move_uploaded_file($_FILES["p_img"]["tmp_name"], $target_file)) {
echo "The file ". htmlspecialchars( basename( $passtype)). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}Editor is loading...