| Author |
Message |
typeman
Joined: 17 Oct 2009 Posts: 92
|
|
Image from URL Copied to Cutenews Image Folder |
|
Hey guys,
Just a quick suggestion and was hoping that someone out there with great PHP knowledge would be able to do this
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! 
|
|
| Tue Nov 24, 2009 6:38 pm |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
DarkSlim

Joined: 06 Aug 2009 Posts: 286 Location: IL |
|
|
| Wed Nov 25, 2009 9:54 am |
|
 |
eberswine

Joined: 26 Apr 2007 Posts: 268
|
|
|
|
I think I understand.
Try this:
Find this in images.mdu (around line 629 or so)
 |  | <a target="_blank" title="<?=$echo['imageTitle']; ?>" href="<?=$config_path_image_upload.'/'.$file; ?>"><?=$file; ?></a> |
Change it to this:
 |  | <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:
Now you can just select it and copy and paste it. 
|
|
| Wed Nov 25, 2009 5:57 pm |
|
 |
typeman
Joined: 17 Oct 2009 Posts: 92
|
|
|
|
 |  | I think I understand.
Try this:
Find this in images.mdu (around line 629 or so)
 |  | <a target="_blank" title="<?=$echo['imageTitle']; ?>" href="<?=$config_path_image_upload.'/'.$file; ?>"><?=$file; ?></a> |
Change it to this:
 |  | <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:
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. 
|
|
| Thu Nov 26, 2009 12:06 am |
|
 |
Chaser

Joined: 17 Feb 2009 Posts: 65
|
|
|
|
I think this is what you need.
Add the following to images.mdu, below the existing <form>.
 |  | <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:
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).
|
|
| Thu Nov 26, 2009 9:16 pm |
|
 |
typeman
Joined: 17 Oct 2009 Posts: 92
|
|
|
|
 |  | I think this is what you need.
Etc, etc.
|
!!!!!
Perfect! Just what i was after. I'll try it in a minute and let you know Thanks a lot
|
|
| Thu Nov 26, 2009 9:49 pm |
|
 |
typeman
Joined: 17 Oct 2009 Posts: 92
|
|
|
|
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-Motorsport-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/data/upimages/admin/post-6103-1259082369.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/data/upimages/admin/post-6103-1259082369.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
Thanks for the help 
|
|
| Thu Nov 26, 2009 10:31 pm |
|
 |
Chaser

Joined: 17 Feb 2009 Posts: 65
|
|
|
| Fri Nov 27, 2009 2:17 am |
|
 |
typeman
Joined: 17 Oct 2009 Posts: 92
|
|
|
|
Damn.
Thanks a lot Really appreciated 
|
|
| Fri Nov 27, 2009 2:45 am |
|
 |
mark99
Joined: 09 Feb 2009 Posts: 127
|
|
|
|
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.
|
|
| Fri Nov 27, 2009 11:34 am |
|
 |
typeman
Joined: 17 Oct 2009 Posts: 92
|
|
|
|
 |  | 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 
|
|
| Fri Nov 27, 2009 10:58 pm |
|
 |
eberswine

Joined: 26 Apr 2007 Posts: 268
|
|
|
|
Great hack. Wonder if there is a way to choose which folder it goes into? (from Remote upload???) default is main...
|
|
| Wed Feb 03, 2010 4:32 pm |
|
 |
samiro

Joined: 20 Apr 2008 Posts: 93 Location: IL |
|
|
|
 |  | I think this is what you need.
Add the following to images.mdu, below the existing <form>.
 |  | <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:
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...
_________________ www.Bwoman.co.il |
|
| Thu Feb 18, 2010 9:55 pm |
|
 |
Wesam
Joined: 29 Sep 2007 Posts: 16 Location: PALESTINE |
|
|
|
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 |
|
| Sat Mar 06, 2010 3:49 pm |
 |
 |
samiro

Joined: 20 Apr 2008 Posts: 93 Location: IL |
|
|
|
pleaseee
were to Add to images.mdu, below the <form>.
wich form ?
witch line !?
_________________ www.Bwoman.co.il |
|
| Sat Mar 06, 2010 3:58 pm |
|
 |
|