PHP Upload Add domain name
function Ajaxfile () {
foreach (lib_request:: $files as $filename = + $value) {
$picname = lib_request:: $files [$filename] [' name '];
$picsize = lib_request:: $files [$filename] [' size '];
if ($picname! = "") {
if ($picsize > 1024000) {
echo Json_encode (Array (
' Code ' = '-1 ',
' title ' = ' picture upload ',
' msg ' = ' picture size cannot exceed 1M '
));
Exit ();
}
$type = Get_extension ($picname);
if ($type! = "gif" && $type! = "jpg" && $type! = "JPEG" && $type! = "png") {
echo Json_encode (Array (
' Code ' = '-1 ',
' title ' = ' picture upload ',
' msg ' = ' picture is not in the right format! '
));
Exit ();
}
$upload _path = '/up ';
$rand = rand (100, 999);
$pics = Date ("Ymdhis"). $rand. '.' . $type;
$dir = Date ('/ymdh/');
$pic _path = $upload _path. $dir;
$pic _url = $pic _path. $pics;
if (!file_exists (path_root. $pic _path)) {
Creatfolder (path_root. $pic _path);
}
$PATH _root = Path_root. $pic _url;
Move_uploaded_file (lib_request:: $files [$filename] [' tmp_name '], $pic _path);
if (Request (' type ') = = ' goods ') {
Makethumbnail ($pic _path, $pic _path. ' _290x290.jpg ', 290, 190);
}
}
$arr [$filename] = Array (
' Name ' = $picname,
' Pic ' = $pic _url,
' Size ' = $picsize
);
}
echo Json_encode ($arr);
Exit ();
}
The path obtained after uploading is/up/xxxxx/xxxxx.jpg
I would like to change to: http://www.xxxx.com//up/xxxxx/xxxxx.jpg
------to solve the idea----------------------
An estimate is to want a change URL?
$pic _url = ' http://www.xxxx.com/'. $pic _path. $pics;
Is that so? The question is not clear haha.
------to solve the idea----------------------
What do you mean by that? I don't understand.
If it's the path inside the database, you can update it.
If it is uploaded to a different server, this should not be