Copy link to clipboard
Copied
Hello everyone,
Have a lil issue I cant seem to figure out.
I have a basic upload box which works great, but i want a way to pull thumbnails from embedded videos. well I have figured out how to do this, but the image i need is stored in url form. (http://www.site.com/image.jpg) My upload field only accepts files already on the computer, not external links to images.
I already have a script that uploads the image and does a ton of stuff to it, and I dont want to edit it much. My problem is getting the script to accept a external image url, instead of a file location.
code for the upload field:
| <input class="filebox" size="36" type="file" id="uploadthumb" name="uploadthumb"<?php if (isset($_POST['uploadthumb'])) { echo "value='".stripslashes($_POST['uploadthumb'])."'" ; } ?>/> |
script code:
$dbthumb = ''; if (! empty($_FILES['uploadthumb']['tmp_name'])) { $thumbfilename = str_replace(" ", "_", $_FILES['uploadthumb']['name']) ; $thumbfilename = md5(uniqid(rand())).'_'.$thumbfilename ; $maxsize = 10000 ; if ($_FILES['uploadthumb']['size'] < $maxsize * 1024) { $thumbfilename = str_replace(" ", "_", $_FILES['uploadthumb']['name']) ; $thumbfilename = md5(uniqid(rand())).'_'.$thumbfilename ; //upload the thumbnail if one was specified $maxsize = 10000 ; if ($_FILES['uploadthumb']['size'] < $maxsize * 1024) { $filename = $_FILES['uploadthumb']['name'] ; $filename_without_ext = $filename ; $ext_pos = strrchr($filename, '.') ; if ($ext_pos !== false) { $filename_without_ext = substr($filename, 0, -strlen($ext_pos)) ; } $ext = strtolower(substr($filename, strrpos($filename, '.') + 1)) ; //img ext removed here $img_exts = array('nowayhoe') ; if (array_search($ext, $img_exts) !== FALSE) { if (move_uploaded_file($_FILES['uploadthumb']['tmp_name'], 'uploads/thumbs/'.$thumbfilename)) { $thumb_name = str_replace("'","",$title); //createThumb($thumbfilename, getSetting("avatar_h", $db), getSetting("avatar_w", $db), 'uploads/thumbs/', 'uploads/thumbs/', $title.".jpg") ; createThumb($thumbfilename, getSetting("savatar_h", $db), getSetting("savatar_w", $db), 'uploads/thumbs/', 'uploads/thumbs/', $title.".jpg") ; $dbthumb = $thumb_name ; } } else { $errorresult = "th" ; } } } }
basically I want to be able to paste a "http://www.site.com/image.jpg" into the what is not a upload field and have the script pull the image and package it in a way so that it can be used in my current script.
I found a few how tos for uploading external links, such as:
$contents= file_get_contents('http://mydomain.com/folder/image.jpg');
but just not sure how to integrate them into my current script or the upload field, I know i cant change it to text field, so how do I get the link in there? or can I... confused, everyhitng ive tried hasnt worked so far!
thanks much for any help you might provide!
Copy link to clipboard
Copied
>My upload field only accepts files already on the computer, not external links to images.
Sorry, I don't understand. Why can't you use a simple text field to pass the url string to the script and store that url in the database? Then simply reference that url for your images.
Copy link to clipboard
Copied
Well my script resizes, makes full sizes, adjusts quality, makes a seo filename etc etc... So I need a way to pass the external filename to the script and have it do what it do. I would like a simple solution but I'm not sure that would work, my script (the first part) is posted, what are my options? I have to admit I'm not an expert in that area
Copy link to clipboard
Copied
Do you want to store the file referenced in the url locally, or simply resize on the fly when outputting?
Copy link to clipboard
Copied
I want to store it on my web server. A few copies actually.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more