как когда переменная пуста положить этот статический HTML-код в PHP

0

Надеюсь, все будет хорошо... Я хочу сделать что-то вроде того, что у меня есть загрузчик изображений php, вот ссылка на загрузчик: http://alitechn.w08.wh-2.com/undo_testing/uploader/upload.php

поэтому, когда кто-то открывает ссылку, поэтому изображение показывает пустое, я хочу добавить какое-то изображение в статический html, но обычно, когда кто-то загружает изображение, чтобы потом новое изображение заменило статическое изображение..!

вот полный код файла upload.php:

<?php
    $fulltarget = '';

@$submit=$_POST['sub'];
if(isset($submit))
{
$name=$_FILES['img']['name'];
$type=$_FILES['img']['type'];

$size=($_FILES['img']['size'])/1024;

$ext=end(explode('.',$name));
if (($ext == "gif")
|| ($ext == "jpeg")
|| ($ext == "jpg")
|| ($ext =="png")
&& ($size > 30))
{


############################## File Renaming ###################################################

$newname=uniqid();
//$ext=end(explode('.',$name));
$fullname=$newname.".".$ext;
$target="pics/";

$fulltarget="http://alitechn.w08.wh-2.com/undo_testing/uploader/{$target}{$fullname}";
if($should_display_static){
$fulltarget="http://www.ipic-uk.com/images/homepage/upload_your_photo.png";


}
if(move_uploaded_file($_FILES['img']['tmp_name'],$fulltarget))
{
echo "Success";
}
else
{
echo "Failed";
}
############################## File Renaming end ###################################################
}
else{
echo "not successful";
}
}
?>
    <div>
 <div id="a1">
 <form name="frm" method="post" enctype="multipart/form-data">
 <div class="upload" style="width: 157px; height: 57px">  
  <input type="file" class="dark-button" name="img" style="width: 88px; height: 29px" /></div>
 <input type="submit" class="auto-style1" value="Store" style="width: 149px; height: 36px" /> 
<style type="text/css">
.styled-button-12 {
background:#5B74A8;
background:-moz-linear-gradient(top,#5B74A8 0%,#5B74A8 100%);
background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#5B74A8),color-stop(100%,#5B74A8));
background:-webkit-linear-gradient(top,#5B74A8 0%,#5B74A8 100%);
background:-o-linear-gradient(top,#5B74A8 0%,#5B74A8 100%);
background:-ms-linear-gradient(top,#5B74A8 0%,#5B74A8 100%);
background:linear-gradient(top,#5B74A8 0%,#5B74A8 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#5B74A8',endColorstr='#5B74A8',GradientType=0);
padding:2px 6px;
color:#fff;
font-family:'Helvetica',sans-serif;
font-size:11px;
border-radius:0;
-moz-border-radius:0;
-webkit-border-radius:0;
border:1px solid #1A356E
}
.auto-style1 {
background: #5B74A8;
background: -moz-linear-gradient(top,#5B74A8 0%,#5B74A8 100%);
background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#5B74A8),color-stop(100%,#5B74A8));
background: -webkit-linear-gradient(top,#5B74A8 0%,#5B74A8 100%);
background: -o-linear-gradient(top,#5B74A8 0%,#5B74A8 100%);
background: -ms-linear-gradient(top,#5B74A8 0%,#5B74A8 100%);
background: #5B74A8;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#5B74A8',endColorstr='#5B74A8',GradientType=0);
padding: 2px 6px;
color: #fff;
font-family: 'Helvetica',sans-serif;
font-size: 11px;
border-radius: 0;
-moz-border-radius: 0;
-webkit-border-radius: 0;
border: 1px solid #1A356E;
margin-left: 162;
}
</style>
</form>
</div>
<div id="a2">

<?php echo "

<html>
<head>
<title>Aviary Photo Editer</title>
<!-- Load Feather code -->
<script type='text/javascript' src='http://feather.aviary.com/js/feather.js'></script>
<!-- Instantiate Feather -->
<script type='text/javascript'>
var featherEditor = new Aviary.Feather({
apiKey: 'ceegvx4siylhayrr',
apiVersion: 3,
theme: 'dark', // Check out our new 'light' and 'dark' themes!
tools: 'enhance,frames,crop,orientation,brightness,saturation,sharpness,draw,redeye,blemish,effects,stickers,resize,focus,contrast,warmth,colorsplash,text,whiten',
appendTo: '',
onSave: function(imageID, newURL) {
    var img = document.getElementById(imageID);
    img.src = newURL;
    var object = document.getElementsByName('cardlink');
    object.item(0).value=newURL;
    input.value= newURL;    

},
onError: function(errorObj) {
    alert(errorObj.message);
}
});
function launchEditor(id, src) {
featherEditor.launch({
    image: id,
    url: src
 });
return false;
}
 </script>
</head>

<body>

<div id='injection_site'></div>

<img id='image1' src='".$fulltarget."' width='300px' height='400px'/>

<p><input type='image' src='http://images.aviary.com/images/edit-photo.png' value='Edit photo' onclick=\"return launchEditor('image1','".$fulltarget."');\" /></p>";



?>

<div onSave="function(imageID, newURL);">
<form action="contact-form/index.php" method="post">
<div><label for="cardlink">Card Image Link:<input type="text" name="cardlink" id="cardlink" style="width: 323px; height: 25px" /></label></div>

                    <a href="#" onclick="$(this).closest('form').submit()"  class="dark-button add-to-cart">Submit</a>



                </input>    </form>
 </div>
</div>
Теги:

1 ответ

0
Лучший ответ

Измените $ fulltarget как абсолютный путь к изображению, которое вы хотите отобразить. Затем, когда вы определяете, что хотите показать статическое изображение, измените $ fulltarget, чтобы указать на статическое изображение.

$fulltarget="http://alitechn.w08.wh-2.com/undo_testing/uploader/{$target}{$fullname}";

затем проверьте, хотите ли вы отображать статическое изображение (вы не указываете критерии)

if($should_display_static)[
    $fulltarget="http://path/to/static/image.jpg";
}

то, очевидно, измените код img на:

<img id='image1' src='".$fulltarget."' width='300px' height='400px'/>
  • 0
    Можете ли вы дать мне код для этого, пожалуйста ...!
  • 0
    см редактировать для деталей
Показать ещё 9 комментариев

Ещё вопросы

Сообщество Overcoder
Наверх
Меню