本文介绍了用于上传文件不起作用的PHP代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?php
//this function returns a random 5-char filename with the jpg extension
function randomFileName()
{
$length = 5;
$characters = 'abcdefghijklmnopqrstuvwxyz';
$string = '';
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];
}
return $string . '.jpg';
}
//create the random filename string and uploads target variables
$randomString = randomFileName();
$target = 'http://pindots.com/admin/pin/upload/';
$target = $target . $randomString;
if(move_uploaded_file($_FILES['media']['tmp_name'], $target))
{
//output the location to our image
echo 'http://pindots.com/admin/pin/upload' . $randomString;
}
else
{
echo "false";
}
?>
推荐答案
这篇关于用于上传文件不起作用的PHP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!