رفتن به مطلب

آپلود عکس از آدرس با تغییرنام آن


پست های پیشنهاد شده

درود

دنبال یک افزونه یا اسکریپت بسیار ساده پی اچ پی هستم

که با بخش رسانه وردپرس کار نکنه - یک اسکریپت جدا باشه

و بشه در اون ادرس یک عکس خارجی (external ) رو وارد کرد

و اون اسکریپت یک keyword مورد نظر من که از قبل در تنظیمات وارد شده رو در ادرس اون عکس وارد کنه

و عکس رو اپ کنه در هاست من

افزونه ای هست ؟

اسکریپت جداگانه php هست ؟

تشکر.

لینک به ارسال

این کد رو من روی یکی از اسکریپت هام دارم که رایگانه

این کارش اینه که لینک رو می گیره و اپ میکنه در هاست خودم

حالا فرضا ما یک $key اگر در این تعریف کنیم ، بخوایم این کی ورد رو اضافه کنه قبل از فایل ذخیره شده در سایت چطوری میشه ؟


<?php
require('config.php');
function is_valid_url($link)
{
$link = @parse_url($link);
if ( ! $link) {
return false;
}
$link = array_map('trim', $link);
$link['port'] = (!isset($link['port'])) ? 80 : (int)$link['port'];
$path = (isset($link['path'])) ? $link['path'] : '';
if ($path == '')
{
$path = '/';
}
$path .= ( isset ( $link['query'] ) ) ? "?$link[query]" : '';
if ( isset ( $link['host'] ) AND $link['host'] != gethostbyname ( $link['host'] ) )
{
if ( PHP_VERSION >= 5 )
{
$headers = get_headers("$link[scheme]://$link[host]:$link[port]$path");
}
else
{
$fp = fsockopen($link['host'], $link['port'], $errno, $errstr, 30);
if ( ! $fp )
{
return false;
}
fputs($fp, "HEAD $path HTTP/1.1\r\nHost: $link[host]\r\n\r\n");
$headers = fread ( $fp, 128 );
fclose ( $fp );
}
$headers = ( is_array ( $headers ) ) ? implode ( "\n", $headers ) : $headers;
return ( bool ) preg_match ( '#^HTTP/.*\s+[(200|301|302)]+\s#i', $headers );
}
return false;
}
if (isset($_POST['pass']) && isset($_POST['user'])){
if ($_POST['pass'] == $pass && $_POST['user'] == $user){
if (!$pass | !$user | !$save | !$link){
include('./error.php');
}elseif(is_valid_url($link) && copy($link, $upload_folder.'/'.$save)){
include('./index.2.php');
}else{
include('./error.php');
}
}else{
include('./error.php');
}
}
?>

لینک به ارسال

اگر قصد این را دارید که مثلا بعد از انکه فایل آپلود شد روی هاست آخر اسم فایل یک کلمه دلخواه شما بیاد مثلا: testfile.format هست بشه testfilemyname.format

این کد را تست کنید به ابتدای فایل ذخیره شده کلمه مورد نظر شما را اضافه می کند


<?php
require('config.php');
$myword="site";
function is_valid_url($link)
{
$link = @parse_url($link);
if ( ! $link) {
return false;
}
$link = array_map('trim', $link);
$link['port'] = (!isset($link['port'])) ? 80 : (int)$link['port'];
$path = (isset($link['path'])) ? $link['path'] : '';
if ($path == '')
{
$path = '/';
}
$path .= ( isset ( $link['query'] ) ) ? "?$link[query]" : '';
if ( isset ( $link['host'] ) AND $link['host'] != gethostbyname ( $link['host'] ) )
{
if ( PHP_VERSION >= 5 )
{
$headers = get_headers("$link[scheme]://$link[host]:$link[port]$path");
}
else
{
$fp = fsockopen($link['host'], $link['port'], $errno, $errstr, 30);
if ( ! $fp )
{
return false;
}
fputs($fp, "HEAD $path HTTP/1.1\r\nHost: $link[host]\r\n\r\n");
$headers = fread ( $fp, 128 );
fclose ( $fp );
}
$headers = ( is_array ( $headers ) ) ? implode ( "\n", $headers ) : $headers;
return ( bool ) preg_match ( '#^HTTP/.*\s+[(200|301|302)]+\s#i', $headers );
}
return false;
}
if (isset($_POST['pass']) && isset($_POST['user'])){
if ($_POST['pass'] == $pass && $_POST['user'] == $user){
if (!$pass | !$user | !$save | !$link){
include('./error.php');
}elseif(is_valid_url($link) && copy($link, $upload_folder.'/'.$myword.$save)){
include('./index.2.php');
}else{
include('./error.php');
}
}else{
include('./error.php');
}
}
?>

متغییر save$ اینجا از داخل یک فایل دیگه فراخوانی میشه اگر اونو بزارید بهتر میشه راهنمایی کرد

لینک به ارسال

داداش ممنون ، حرف نداشت :):wub: :wub:

فقط یه چیز دیگه هم اگر اوکی بشه محشر میشه

این اسکریپت کوچیک ما، یه index.php هم داره به این شکل :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta content="en-us" http-equiv="Content-Language" />

<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

<title>Link Upload v4.0</title>

<style type="text/css">

/* begin Button */

.art-button-wrapper .art-button

{

display:inline-block;

width: auto;

outline:none;

border:none;

background:none;

line-height:28px;

margin:0 !important;

padding:0 !important;

overflow: visible;

cursor: default;

text-decoration: none !important;

z-index:0;

}

.art-button-wrapper

{

display:inline-block;

position:relative;

height: 28px;

overflow:hidden;

white-space: nowrap;

width: auto;

z-index:0;

}

.art-button-wrapper .art-button

{

display:block;

height: 28px;

font-family: Tahoma;

font-size: 8pt;

font-style: normal;

font-weight: bold;

white-space: nowrap;

text-align: right;

padding: 0 11px !important;

line-height: 28px;

text-decoration: none !important;

color: #0E404E !important;

}

input, select

{

font-family: Tahoma;

font-size: 8pt;

font-style: normal;

font-weight: bold;

}

.art-button-wrapper.hover .art-button, .art-button:hover

{

color: #333333 !important;

text-decoration: none !important;

}

.art-button-wrapper.active .art-button

{

color: #283133 !important;

}

.art-button-wrapper .l, .art-button-wrapper .r

{

display:block;

position:absolute;

z-index:-1;

height: 84px;

background-image: url('http://www.websoftdownload.com/url/Button.png');

}

.art-button-wrapper .l

{

left:0;

right:5px;

}

.art-button-wrapper .r

{

width:401px;

right:0;

clip: rect(auto, auto, auto, 396px);

}

.art-button-wrapper.hover .l, .art-button-wrapper.hover .r

{

top: -28px;

}

.art-button-wrapper.active .l, .art-button-wrapper.active .r

{

top: -56px;

}

/* end Button */

.style1 {

border: 1px solid #CDDCFE;

text-align: center;

}

.style2 {

font-size: 8pt;

}

.style4 {

text-align: center;

}

.style5 {

margin: 10px;

direction: rtl;

}

</style>

</head>

<body>

<table align="center" cellpadding="0" cellspacing="0" style="width: 407px; height: 244px; margin-top: 100px">

<!-- MSTableType="layout" -->

<tr>

<td class="style1" style="height: 244px; width: 405px;">

<font face="Tahoma"><span class="style2">

<table cellpadding="0" cellspacing="0" style="width: 405px; height: 39px">

<!-- MSTableType="layout" -->

<tr>

<td style="width: 242px; " class="style4" valign="top">

<form name=upload method=post action=upload.php>

<font face="Tahoma"><input name="file" style="margin:10px;" type="text" value="http://"></input></font></td>

<td style=" height: 39px; width: 164px;" class="style4" valign="top">

<p class="style5"><span lang="fa">آدرس دانلود مستقیم فایل :</span></p></td>

</tr>

</table>

<table cellpadding="0" cellspacing="0" style="width: 405px; height: 39px">

<!-- MSTableType="layout" -->

<tr>

<td style="width: 241px; " valign="top" class="style4">

<font face="Tahoma">

<input style="margin:10px;" name="save" type="text" value=""></font></td>

<td style="width: 164px; height: 39px" valign="top" class="style4">

<p class="style5"><span lang="fa">ذخیره کردن فایل با نام :</span></p></td>

</tr>

</table>

<table cellpadding="0" cellspacing="0" style="width: 405px; height: 39px">

<!-- MSTableType="layout" -->

<tr>

<td style="width: 241px; " valign="top" class="style4">

<font face="Tahoma">

<input style="margin:10px;" name="user" type="username"></input></font></td>

<td style="width: 164px; height: 39px" valign="top" class="style4">

<p class="style5"><span lang="fa">نام کاربری :</span></p></td>

</tr>

</table>

<?php

require('config.php');

if ($ask_pass == "true"){

echo ' <table cellpadding="0" cellspacing="0" style="width: 405px; height: 39px">

<!-- MSTableType="layout" -->

<tr>

<td style="width: 242px; " valign="top" class="style4">

<font face="Tahoma">

<input style="margin:10px;" name="pass" type="password"></font></td>

<td style="width: 164px; height: 39px" valign="top" class="style4">

<p class="style5">

<span lang="fa">رمز عبور :</span></p>

</td>

</tr>

</table>

';

}

?>

</span>

</br>

<input name="submit" type="Submit" value="آپلود" style="width: 82px">

</input>

<input name="reset" type="reset" value="از نو"></input>

</span>

</font>

</form>

</td>

</tr>

</table>

</body>

</html>

و یک کانفیگ :


<?php
// Ask password for uploading (true or false)
$ask_pass="true";
// Upload password
$pass="mohamad";
$user="mohamad";
$domain="http://mohamad.ir/";
$link=$_POST['file'];
$save=$_POST['save'];
// Upload folder (Permision must be 777)
$upload_folder="file";
?>

برای اپلود هر عکس ما نیازه که نام فایل رو دوباره بزنیم توی فیلد دوم. تا فایل رو با اون نام مورد نظر دریافت کنه

حالا سوال من اینه که میشه کاری که تا نیازی به پر کردن این فیلد نباشه ؟؟ یعنی ما فقط و فقط ادرس یک عکس رو بهش بدیم و اون عکس رو با همون نام خودش بگیره و همون keyword ما رو بزنه بغلش و اپ کنه رو هاست

خیلی ممنون میشم اگر کمک کنی . دمت گرم.

پ.ن > این اسکریپت کامل و رایگان من هست : http://www.xscript.ir/%D8%A7%D8%B3%DA%A9%D8%B1%DB%8C%D9%BE%D8%AA-%D8%A7%D9%BE%D9%84%D9%88%D8%AF-%D8%A7%D8%B2-%D9%84%DB%8C%D9%86%DA%A9.html

لینک به ارسال

این کد را جایگزین فایل کانفینگ کنید: بعد دیگه نیازی نیست قسمت فیلد نام جدید را وارد نمایید


<?php
// Ask password for uploading (true or false)
$ask_pass="true";
// Upload password
$pass="mohamad";
$user="mohamad";
$domain="http://mohamad.ir/";
$link=$_POST['file'];
$ex=explode("/",$link);
$save=end($ex);
// Upload folder (Permision must be 777)
$upload_folder="file";
?>

ویرایش شده توسط I..R
لینک به ارسال

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...