<?php
// Edit upload location here
$destination_path = getcwd().DIRECTORY_SEPARATOR;
$result = 0;
$target_path = $destination_path . basename( $_FILES['myfile']['name']);
$imagetypes = array(
'image/png' => '.png',
'image/gif' => '.gif',
'image/jpeg' => '.jpg',
'image/bmp' => '.bmp');
$ext = $imagetypes[$_FILES['myfile']['type']];
$randval = time();
$newname = $randval . $ext;
if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $newname)) {
echo "<script type='text/javascript'>alert('http://my_site.com/myupluader/$newname');</script>";
$fileurl = 'http://my_site.com/myupluader/$newname';
$result = 1;
}
sleep(1);
?>
<script language="javascript" type="text/javascript">window.top.window.stopUpload('<?php echo $result; ?>', '<?php echo $fileurl; ?>');</script>
<script language="javascript" type="text/javascript">
<!--
function startUpload(){
document.getElementById('myf1_upload_process').style.visibility = 'visible';
document.getElementById('myf1_upload_form').style.visibility = 'hidden';
return true;
}
function stopUpload(success){
var result = '';
if (success == 1){
result = '<span class="mymsg"><\/span>';
editor = ipb.textEditor.getEditor(ipb.topic.fastReplyId);
editor.insert("[img]+$fileurl+[/img]", true );
}
else {
result = '<span class="myemsg">There was an error during file upload!<\/span>';
}
document.getElementById('myf1_upload_process').style.visibility = 'hidden';
document.getElementById('myf1_upload_form').innerHTML = result + '<br/><input type="hidden" name="MAX_FILE_SIZE" value="5000000">File: <input name="myfile" type="file" accept="image/*" size="0" /><input type="submit" name="submitBtn" class="mysbtn" value="Upload" />';
document.getElementById('myf1_upload_form').style.visibility = 'visible';
return true;
}
//-->
</script>
echo заработал, и там ссылка выводится
но никак не получается выводит ссылку в яваскрипт и вставлять его в редакторе: editor.insert("[img]+$fileurl+[/img]", true );