如何使用带有原始文件名的文本框的回显复制
该脚本的步骤。
在文本框中插入链接(如rapidleech),但这里我有2个文本框
通过回显复制上传文件(远程链接) ,我的服务器)(这不起作用)
在文本框中打印文件的HTML信息(我想在这里我有错误)
注意 - 仅图像信息 重要
提示 - 如何获取原始文件名并保存在服务器上?
HTML
<html>
<body>
<form action="upload_file.php" method="post" enctype="multipart">
<label for="file">thumb link : </label>
<input type="text" name="file" id="file" />
<br />
<label for="file2">image link : </label>
<input type="text" name="file2" id="file2" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
PHP
<?php
define ( 'IMAGE_DIR', 'img/' );
define ( 'THUMB_DIR', 'thumb/' );
$thumblink = "file1";
$imglink = "file2";
$printhtml = "printhtml";
$filesize = "size";
$filesizelimit = "limit";
$printtxt = "<center><img src=\"{$thumblink}\"/><br/>
<a href=\"{$imglink}\" target=\"_blank\">download image</a> /
{$filesize} <br/></center>";
// here is dont work show error
// error syntax error, unexpected T_STRING
echo copy("{$thumblink}", THUMB_DIR . '["name"]');
echo copy("{$imglink}", IMAGE_DIR . '["name"]');
//
if ((($_FILES["file2"]["type"] == "image/gif")
|| ($_FILES["file2"]["type"] == "image/jpeg")
|| ($_FILES["file2"]["type"] == "image/pjpeg"))
&& ($_FILES["file2"]["size"] < 2000000))
{
if ($_FILES["file2"]["error"] > 0)
{
echo "Error: " . $_FILES["file2"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file2"]["name"] . "<br />";
echo "Type: " . $_FILES["file2"]["type"] . "<br />";
echo "Size: " . ($_FILES["file2"]["size"] / 1024) . " Kb<br />";
echo "thumb in: " . $_FILES["file1"][THUMB_DIR];
echo "image in: " . $_FILES["file2"][IMAGE_DIR];
echo "<center><img src=\"{$thumblink}\"/><br/>
<a href=\"{$imglink}\" target=\"_blank\">download image</a> /
{$filesize} <br/></center>";
}
}
else
{
echo "Invalid file";
}
?>
Steps of this script.
Insert link in text box (like rapidleech) but here I have 2 text box
Upload files via echo copy (remote link, my server) (This doesn't work)
Print files' HTML info in a textbox (I think here I have an error)
note - Just image information important
note - How can get orginal filename and save on server?
HTML
<html>
<body>
<form action="upload_file.php" method="post" enctype="multipart">
<label for="file">thumb link : </label>
<input type="text" name="file" id="file" />
<br />
<label for="file2">image link : </label>
<input type="text" name="file2" id="file2" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
PHP
<?php
define ( 'IMAGE_DIR', 'img/' );
define ( 'THUMB_DIR', 'thumb/' );
$thumblink = "file1";
$imglink = "file2";
$printhtml = "printhtml";
$filesize = "size";
$filesizelimit = "limit";
$printtxt = "<center><img src=\"{$thumblink}\"/><br/>
<a href=\"{$imglink}\" target=\"_blank\">download image</a> /
{$filesize} <br/></center>";
// here is dont work show error
// error syntax error, unexpected T_STRING
echo copy("{$thumblink}", THUMB_DIR . '["name"]');
echo copy("{$imglink}", IMAGE_DIR . '["name"]');
//
if ((($_FILES["file2"]["type"] == "image/gif")
|| ($_FILES["file2"]["type"] == "image/jpeg")
|| ($_FILES["file2"]["type"] == "image/pjpeg"))
&& ($_FILES["file2"]["size"] < 2000000))
{
if ($_FILES["file2"]["error"] > 0)
{
echo "Error: " . $_FILES["file2"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file2"]["name"] . "<br />";
echo "Type: " . $_FILES["file2"]["type"] . "<br />";
echo "Size: " . ($_FILES["file2"]["size"] / 1024) . " Kb<br />";
echo "thumb in: " . $_FILES["file1"][THUMB_DIR];
echo "image in: " . $_FILES["file2"][IMAGE_DIR];
echo "<center><img src=\"{$thumblink}\"/><br/>
<a href=\"{$imglink}\" target=\"_blank\">download image</a> /
{$filesize} <br/></center>";
}
}
else
{
echo "Invalid file";
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
PHP 常量不能插入到这样的字符串中 - PHP 无法知道您正在使用常量,而不仅仅是一些看起来像常量的文本:
请注意更改:
PHP constants cannot be inserted into a string like that - PHP has no way to know that you're using a constant, and not just some text that happens to look like a constant:
Note the changes:
这是行不通的:
你必须选择 :P echo 或 print :) 否则,如果 print() 返回 TRUE,它将回显“...”,后跟 1。这就是您要找的吗?
另外:
注意到引号是如何相互妨碍的吗?和 THUMB_DIR & IMAGE_DIR 是常量,而不是数组。你到底想在这里做什么?
此外,copy() 返回一个布尔值。为什么要回声呢?如果 copy() 返回 FALSE,则不会显示任何内容。
This can't work:
You've gotta chose :P Either echo, or print :) Or else, it will echo "..." followed by a 1 if print() returns TRUE. Is that what you are looking for ?
Also:
Notice how the quotes get in the way of each other ? And THUMB_DIR & IMAGE_DIR are constants, and not arrays. What do you want do here exactly ?
Also, copy() returns a boolean value. Why echo it ? It will show nothing if copy() returns FALSE.
请将您的
define
更改为:那么
仍然不明白为什么要回显这些?..
您还需要更改原始文件名:
please change your
define
to:Then
still don't understand why should you echo these?..
you also need to change original file name: