Jump to content

Recommended Posts

<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">The file was uploaded successfully!<\/span>';
  }
  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/>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';    
editor = ipb.textEditor.getEditor(ipb.topic.fastReplyId);
editor.insert("[img= URL For Upluaded Photo After Upload ]", true );
    return true;   
}
//-->
</script>

 

<?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)) {
	  $result = 1;
  }

  sleep(1);
?>

<script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php echo $result; ?>);</script>

 

editor.insert("[img= URL For Upluaded Photo After Upload ]", true ); 

 

How to receive link after upload instead "URL For Upluaded Photo After Upload"

Link to comment
https://forums.phpfreaks.com/topic/271525-how-to-receive-link-after-upload/
Share on other sites

@Christian F., Thank you for your attention

 

Tried but failed ... please write your version of how to implement, if you have free time:

editor.insert("[img= URL For Upluaded Photo After Upload ]", true ); 

???

Edited by AnomaIy

I'm afraid I won't be doing that, as I'm not here to write the code for others. At least not without getting paid for it.

However, if you post what you tried to do, and explained how it "failed", then I'm sure I (or someone else) can help you figure out what you did wrong. That's what I'm here for: To help others learn. ;)

The problem you're having is that the file you're editing is not being re-parsed by the server when uploading the file, which is why you're using AJAX. So you'll need to edit the actual file that does the uploading, the code in the last box, to echo out the name and location of the image.

That will be sent to the calling AJAX code, in which where you can retrieve it from the result. I recommend reading up a bit more up on how AJAX works, and possibly using jQuery if you're not already.

 

Bit difficult to say exactly what you should do, as there seems to be some code missing in the blocks you've posted.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.