Jump to content

Upload images with URL


vxda
 Share

Recommended Posts

Hi
on my site users can post new articles, and withing them upload images i made this:

 

$pic= new WireUpload('fileUploadInput');
			$pic->setMaxFiles(1);
			$pic->setOverwrite(false);
			$pic->setDestinationPath($upload_path);
			$pic->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif'));

			$files = $pic->execute();
			if(!count($files)) {
				$pic->error("Sorry, but you need to add a photo!");
				return false;
			}

The above works with <input type="file"/>

Is there a way to upload files thru url ?
 

exaple :
<input type="text" value="http://processwire.com/site/assets/files/1/fields.jpg">

Link to comment
Share on other sites

Can you not just do this when they submit the text field containing the URL?

$pic->add($input->post->your-text-field);

Not sure it works with URLs but that's the way to test it :)

  • Like 1
Link to comment
Share on other sites

You can simply use a textfield for an URL and also you do not need to use the WireUpload if you finally want to use the image(s) within an pw images field.

For that you simply can use $page->images->add('URL_from_text');

But remember to not use $input->post->your-text-field without first validating it. You need to make sure you only got an URL!

  • Like 1
Link to comment
Share on other sites

Another question:

in my form i got
 

<input type="text" name="url"/>

now in php i want to check if this is image, if it is attatch it to fieldinput image_url,
but if its url to youtube or vimeo attatch it to textarea video_url.

im using this plugin for vids:
http://modules.processwire.com/modules/textformatter-video-embed/
 

Is there a way to check if the link is a img and its not broken ? if this img acculy exsist ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...