vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Upload image via url (https://vborg.vbsupport.ru/showthread.php?t=147525)

Wizardjv 05-18-2007 09:00 AM

Upload image via url
 
Hi I was wondering if someone could help with this. I have been looking some code I can use to upload images via urls. But I cant seem to find it anywhere and I tryed making one but cant get it to work. Does anyone know how to do this or know where I can find example?

Symbian Forum 05-18-2007 09:32 AM

I too wanna know about this !

nico_swd 05-18-2007 11:39 AM

I wrote a class for this.

http://www.bytemycode.com/snippets/snippet/528/

Wizardjv 05-18-2007 02:26 PM

Very interesting.. So I tried it out and seems to work fine. I was wondering though say I already have an upload script and would just like to incorporate it with mine. I dont know much about classes.

But say I wanted to save the file to a temp buffer and then pass it to this script.

HTML Code:

// get variables for fields on upload screen
        $thefile = $_FILES['thefile'];
        $tos = $_POST['tos'];

        $currentip = $_SERVER['REMOTE_ADDR'];
        $messages = "";

So It can output like normal.

How would I send it there. I have tried with normal php setting an else and array. But its not working im wondering if its the class? If so could you help me? I would greatly appreciate it


Ok so this is the acctual function used to transload?

HTML Code:

    /**
        *      Transloads a file from another host to the upload directory.
        *
        *      @return                boolean
        */
        function transload()
        {
                if (ini_get('allow_url_fopen') == 0)
                {
                        $this->set_error($this->default_errors[15]);
                        return false;
                }
     
                if (!$this->is_valid_upload_path())
                {
                        return false;
                }
       
                if (!empty($this->transload))
                {
                        $filename = basename($this->transload);
                        $contents = '';
                     
                        if (!$this->is_valid_file($filename, false))
                        {
                                return false;
                        }

                        set_time_limit(0);
                        @ini_set('user_agent', 'PHP');

                        if (!($fp = @fopen($this->transload, 'rb')))
                        {
                                $this->set_error($this->default_errors[14]);
                                return false;
                        }
                     
                        while (!feof($fp))
                        {
                                $contents .= fread($fp, 8192);
                             
                                if ($this->max_size AND (strlen($contents) > $this->max_size))
                                {
                                        $this->set_error(sprintf($this->default_errors[9], $this->max_size));
                                        return false;
                                }
                        }
                     
                        fclose($fp);
     
                        if ($upload = @fopen($this->upload_path . $this->subdir . $this->rand_name($filename), 'w'))
                        {
                                fwrite($upload, $contents);
                                fclose($upload);
                        }
                     
                        $this->uploaded_files[] = $filename;
                        return true;
                }
        }

Ok so say I wanted to use this function to load the uploaded file thats grabbed and turn it into

$thefile

So It loads into my already setup script? I am trying to understand it but..It seems like different than what im used to. Any help would be appreciated

Wizardjv 05-20-2007 07:14 AM

No one can help me with this?

neopet001 06-20-2007 07:02 AM

Hmm, I'm having a big headache with this problem, who can help me???


All times are GMT. The time now is 03:55 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00960 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_html_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete