我有一个脚本可以从您的计算机上传文件到服务器。它工作正常,基本上是一个
<form enctype="multipart/form-data" action="post_img_upload.php?id='.$topicid.'" method="POST">
<input name="uploaded_file" type="file" />
<input type="submit" value="Subila" />
然后,post_img_upload.php就像这样开始:
$target = "pics/";
$fileName = $target . $_FILES["uploaded_file"]["name"]; // The file name
$fileTmpLoc = $_FILES["uploaded_file"]["tmp_name"]; // File in the PHP tmp folder
$fileType = $_FILES["uploaded_file"]["type"]; // The type of file it is
$fileSize = $_FILES["uploaded_file"]["size"]; // File size in bytes
$fileErrorMsg = $_FILES["uploaded_file"]["error"]; // 0 for false... and 1 for true
$fileName = preg_replace('#[^a-z.0-9]#i', '', $fileName); // filter the $filename
$kaboom = explode(".", $fileName); // Split file name into an array using the dot
$fileExt = end($kaboom);
现在我想要选择上传具有网址的文件。另一种形式基本上是
<form action="post_img_url_upload.php?id='.$topicid.'" method="POST">
<input name="url" type="text" size="100" />
<input type="submit" value="Copiar"/>
我想让post_img_url_upload.php类似于post_img_upload.php。 我该怎么做? 我怎么能基本上写
$fileName = $target . $_FILES["url"]["name"];
?它可行吗? 谢谢!
答案 0 :(得分:1)
AFAIK,没有。服务器只会获取url字符串,然后应该尝试获取图像本身(而不是从客户端传输的图像数据)。你可以google for&#34; php外部请求&#34;因为有几种方法可以做到(cURL,远程文件访问等)。