Image from URL Copied to Cutenews Image Folder

Post your suggestions for the script here.

Image from URL Copied to Cutenews Image Folder

Postby typeman » Tue Nov 24, 2009 6:38 pm

Hey guys,

Just a quick suggestion and was hoping that someone out there with great PHP knowledge would be able to do this :D

Basically, I was hoping that maybe it would be possible to add another field to the image upload section that would allow users to copy an image url, and after clicking submit, the image would then be copied to your cutenews database. This would save having to download/upload an image as it would be pretty much instant.

Hopefully someone can muster this up! :D
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby DarkSlim » Wed Nov 25, 2009 9:54 am

Hmm I would try that but my images.mdu still isn't working properly :\
User avatar
DarkSlim
 
Posts: 296
Joined: Thu Aug 06, 2009 4:18 pm
Location: IL

Postby eberswine » Wed Nov 25, 2009 5:57 pm

I think I understand.

Try this:

Find this in images.mdu (around line 629 or so)
Code: Select all
<a target="_blank" title="<?=$echo['imageTitle']; ?>" href="<?=$config_path_image_upload.'/'.$file; ?>"><?=$file; ?></a>


Change it to this:
Code: Select all
<a target="_blank" title="<?=$echo['imageTitle']; ?>" href="<?=$config_path_image_upload.'/'.$file; ?>"><?=$file; ?></a><br /><input name="textfield" size="15" id="textfield" style="border: 2px solid rgb(204, 204, 204);" value="<?=$config_path_image_upload.'/'.$file; ?>" onclick="select()" type="text">


and you will get this:

Image

Now you can just select it and copy and paste it. :-)
User avatar
eberswine
 
Posts: 281
Joined: Thu Apr 26, 2007 7:23 pm

Postby typeman » Thu Nov 26, 2009 12:06 am

eberswine wrote:I think I understand.

Try this:

Find this in images.mdu (around line 629 or so)
Code: Select all
<a target="_blank" title="<?=$echo['imageTitle']; ?>" href="<?=$config_path_image_upload.'/'.$file; ?>"><?=$file; ?></a>


Change it to this:
Code: Select all
<a target="_blank" title="<?=$echo['imageTitle']; ?>" href="<?=$config_path_image_upload.'/'.$file; ?>"><?=$file; ?></a><br /><input name="textfield" size="15" id="textfield" style="border: 2px solid rgb(204, 204, 204);" value="<?=$config_path_image_upload.'/'.$file; ?>" onclick="select()" type="text">


and you will get this:

Image

Now you can just select it and copy and paste it. :-)


Hey, thanks for the help, but unfortunately, that wasn't what I was after. (but still a great idea nonetheless).

I'll try and explain better:

- Basically, you copy an image's URL (which isn't based on your server)
- Paste that into a box on YOUR server
- When you click upload, that same image is then copied to your server so it's under the URL of www.mysite.com/images/etc...

So instead of uploading from your computer, you can upload from a URL.

Hopefully that explanation is simplier. :D
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby Chaser » Thu Nov 26, 2009 9:16 pm

I think this is what you need.

Add the following to images.mdu, below the existing <form>.
Code: Select all
<b>Remote upload</b>
<form enctype="multipart/form-data" action="<?php echo $PHP_SELF; ?>&loadurl=true" method="post">
<table border="0" cellspacing="1" cellpadding="5"  width="300" class="panel">
  <tr>
    <td>
      <b>URL:</b>
    </td>
   
    <td>
      <input type="text" name="from" size="40">
   </td>
  </tr>
 
  <tr>
    <td>
      <b>Filename:</b>
     <br />(optional)
   </td>
   
    <td>
      <input type="text" name="to" size="40">
   </td>
  </tr>
 
  <tr>
    <td colspan="2">
      <input type="submit" value="Submit">
   </td>
  </tr>
 
</table>
</form>

<?php
if ($_GET[loadurl]){

   if ($_POST[from] == ""){
      echo 'Enter a url.';
    
   } else{
        $from = $_POST[from];
       
        if($_POST[to] == "") {
           $to = basename("$from");
         
        } else $to = $_POST[to];
       
        if (!copy("$_POST[from]","$folder/$to")){
           echo 'File upload failed.';
         
        }

    }

}

?>


It looks like this:

Image

Copy the link to the image in the first field (example: http://path_to_image.com/img.jpg). In the second (optional) field you can enter a different filename instead of the original (ex: my_image.jpg).
User avatar
Chaser
 
Posts: 72
Joined: Tue Feb 17, 2009 7:26 pm

Postby typeman » Thu Nov 26, 2009 9:49 pm

Chaser wrote:I think this is what you need.

Etc, etc.



:D!!!!!

Perfect! Just what i was after. I'll try it in a minute and let you know :) Thanks a lot
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby typeman » Thu Nov 26, 2009 10:31 pm

Damn, got some errors... :(

Warning: copy() [function.copy]: URL file-access is disabled in the server configuration in /home/baxyzco1/public_html/cat3/cutenews/inc/mod/images.mdu on line 519

Warning: copy(http://www.my360.com.au/img/game/Forza- ... rt-3-1.jpg) [function.copy]: failed to open stream: no suitable wrapper could be found in /home/baxyzco1/public_html/cat3/cutenews/inc/mod/images.mdu on line 519
File upload failed.


This came up when I tried to upload the image.

However, this error was already there after uploading and editing your code:


Warning: getimagesize() [function.getimagesize]: URL file-access is disabled in the server configuration in /home/baxyzco1/public_html/cat3/cutenews/inc/mod/images.mdu on line 637

Warning: getimagesize(http://www.baxy-z.com/cat3/cutenews/dat ... 082369.jpg) [function.getimagesize]: failed to open stream: no suitable wrapper could be found in /home/baxyzco1/public_html/cat3/cutenews/inc/mod/images.mdu on line 637

Warning: getimagesize() [function.getimagesize]: URL file-access is disabled in the server configuration in /home/baxyzco1/public_html/cat3/cutenews/inc/mod/images.mdu on line 638

Warning: getimagesize(http://www.baxy-z.com/cat3/cutenews/dat ... 082369.jpg) [function.getimagesize]: failed to open stream: no suitable wrapper could be found in /home/baxyzco1/public_html/cat3/cutenews/inc/mod/images.mdu on line 638


Sorry :P

Thanks for the help :)
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby Chaser » Fri Nov 27, 2009 2:17 am

It seems your hoster has disabled url access in the php settings. :(
http://de.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

I will sleep on it.
User avatar
Chaser
 
Posts: 72
Joined: Tue Feb 17, 2009 7:26 pm

Postby typeman » Fri Nov 27, 2009 2:45 am

Chaser wrote:It seems your hoster has disabled url access in the php settings. :(
http://de.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

I will sleep on it.


Damn. :(

Thanks a lot :) Really appreciated :D
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby mark99 » Fri Nov 27, 2009 11:34 am

Simple, assuming your host allows this, make your own php.ini file and just add this line:

allow_url_fopen = 1

Then upload that to the root dir of your cutenewsru directory. This will make it work again, even under PHP5. Personally though most modern scripts use Curl because fopen has a few security problems.
mark99
 
Posts: 123
Joined: Mon Feb 09, 2009 6:01 pm

Postby typeman » Fri Nov 27, 2009 10:58 pm

mark99 wrote:Simple, assuming your host allows this, make your own php.ini file and just add this line:

allow_url_fopen = 1

Then upload that to the root dir of your cutenewsru directory. This will make it work again, even under PHP5. Personally though most modern scripts use Curl because fopen has a few security problems.


Brilliant! :) Thank you both for your help! Works like a charm :)
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby eberswine » Wed Feb 03, 2010 4:32 pm

Great hack. Wonder if there is a way to choose which folder it goes into? (from Remote upload???) default is main...
User avatar
eberswine
 
Posts: 281
Joined: Thu Apr 26, 2007 7:23 pm

Postby samiro » Thu Feb 18, 2010 9:55 pm

Chaser wrote:I think this is what you need.

Add the following to images.mdu, below the existing <form>.
Code: Select all
<b>Remote upload</b>
<form enctype="multipart/form-data" action="<?php echo $PHP_SELF; ?>&loadurl=true" method="post">
<table border="0" cellspacing="1" cellpadding="5"  width="300" class="panel">
  <tr>
    <td>
      <b>URL:</b>
    </td>
   
    <td>
      <input type="text" name="from" size="40">
   </td>
  </tr>
 
  <tr>
    <td>
      <b>Filename:</b>
     <br />(optional)
   </td>
   
    <td>
      <input type="text" name="to" size="40">
   </td>
  </tr>
 
  <tr>
    <td colspan="2">
      <input type="submit" value="Submit">
   </td>
  </tr>
 
</table>
</form>

<?php
if ($_GET[loadurl]){

   if ($_POST[from] == ""){
      echo 'Enter a url.';
    
   } else{
        $from = $_POST[from];
       
        if($_POST[to] == "") {
           $to = basename("$from");
         
        } else $to = $_POST[to];
       
        if (!copy("$_POST[from]","$folder/$to")){
           echo 'File upload failed.';
         
        }

    }

}

?>


It looks like this:

Image

Copy the link to the image in the first field (example: http://path_to_image.com/img.jpg). In the second (optional) field you can enter a different filename instead of the original (ex: my_image.jpg).


where to add this code? there is alot fo "forms" !!?!
thank you...
User avatar
samiro
 
Posts: 103
Joined: Sun Apr 20, 2008 1:52 pm
Location: IL

Postby Wesam » Sat Mar 06, 2010 3:49 pm

Great Fix

Help Needed to improve this Fix

Can any one help me to have thums after uploaded image from URL

This fix was great and I test it and every thing goes fine, but one problem is their

After you upload the image, their is no thumb for the image, only normal image

Please kindly fix it to make thumb

Thank you
LONG LIVE PALESTINE
Wesam
 
Posts: 16
Joined: Sat Sep 29, 2007 9:25 pm
Location: PALESTINE

Postby samiro » Sat Mar 06, 2010 3:58 pm

pleaseee

were to Add to images.mdu, below the <form>.
wich form ?
witch line !?
User avatar
samiro
 
Posts: 103
Joined: Sun Apr 20, 2008 1:52 pm
Location: IL

Next

Return to Suggestions



Who is online

Users browsing this forum: No registered users and 0 guests

cron