Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Скриптовые языки программирования > PHP
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 20.07.2014, 14:35   #1
vertu81
Пользователь
 
Регистрация: 09.04.2014
Сообщений: 11
Сообщение Download file from link

PHP код:
<?php
/*
 * Converts the file *.png server side to output.pdf
 * Uploads the file from client side and track the status
 */


// for testing it could be helpful...
ini_set('display_errors'1);
 
 
require_once 
'CloudConvert.class.php';

// insert your API key here
$apikey "6BbZ5G_HhYRcfKSJhrOxjnFU0KJbrflnXHbkUxslUziDZ1Fcy8Hf81AkLrB7YTHNBBoYQlGPkS9GtCsbuKN0sg";

// Get the Process URL
$process CloudConvert::createProcess("docx""jpg"$apikey);
$url $process -> getURL();
if(!empty(
$url)) {
?>
<html>
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    </head>
    <body>
        <h3>Process: <?=$url ?></h3>
        
        <label for="file">Please select a PNG file</label>
        <form action="<?=$url ?>" method="POST" enctype="multipart/form-data" id="form" target="hiddenframe">
            <input type="hidden" name="input" value="upload">
            <input type="hidden" name="format" value="jpg">
            <input type="file" name="file">
            <input type="submit">
        </form>
        
        <!-- used for uploading the file to prevent page reload -->
        <iframe frameborder="0" width="0" height="0" name="hiddenframe" id="hiddenframe"></iframe>
        
        <!-- display current status -->
        <pre id="status"></pre>                                        
        
        
        






        <script>
                        $(document).ready(function() {

                var getstatus = function() {

                    $.ajax({
                        url : "<?=$url ?>
                        ",
                        }).done(function(data) {
                        // update info
                        $('#status').text('Step ' + data.step + ': ' + data.message);

                        // check status every second
                        if (data.step != 'error' && data.step != 'finished') {
                        window.setTimeout(getstatus, 1000);
                        }

                        // finsihed ? -> echo download URL
                        if(data.step == 'finished') {
                        $('#status').parent().append('<a href="' + data.output.url + '">Download file</a>');
                        }

                        });

                        }

                        $('#form').submit(function() {
                        $('#status').text('Uploading...');
                        });

                        $('#hiddenframe').load(function() {
                        // iframe loaded: file is uploaded, check the status
                        getstatus();
                        });

                        });
        </script>

    </body>
</html>

<? }

 
$url  $url;
    
$path 'a-large-file.zip';

    
$fp fopen($path'w');

    
$ch curl_init($url);
    
curl_setopt($chCURLOPT_FILE$fp);

    
$data curl_exec($ch);

    
curl_close($ch);
    
fclose($fp);


 
?>
он генерирует docx >> jpg

вот этот код должен загрузить изображения на сервер
но он качает файл до конвертации

http://i.imgur.com/83demYo.jpg

как можно поставить data.output.url вместо $url


PHP код:
<? }
 
 
$url  $url;
    
$path '1.jpg';
 
    
$fp fopen($path'w');
 
    
$ch curl_init($url);
    
curl_setopt($chCURLOPT_FILE$fp);
 
    
$data curl_exec($ch);
 
    
curl_close($ch);
    
fclose($fp);
 
 
 
?>
vertu81 вне форума Ответить с цитированием
Старый 20.07.2014, 17:29   #2
ADSoft
Старожил
 
Регистрация: 25.02.2007
Сообщений: 4,160
По умолчанию

передавать через Ajax
ADSoft вне форума Ответить с цитированием
Старый 20.07.2014, 17:35   #3
vertu81
Пользователь
 
Регистрация: 09.04.2014
Сообщений: 11
По умолчанию

Цитата:
Сообщение от ADSoft Посмотреть сообщение
передавать через Ajax
я понимаю что где то тут но как ?

PHP код:
// finsihed ? -> echo download URL 
                        
if(data.step == 'finished') { 
                        $(
'#status').parent().append('<a href="' data.output.url '">Download file</a>'); 
                        } 
vertu81 вне форума Ответить с цитированием
Старый 20.07.2014, 18:14   #4
ADSoft
Старожил
 
Регистрация: 25.02.2007
Сообщений: 4,160
По умолчанию

как то так -
Код:
 $.ajax({
                        url : "upload.php?name="+data.output.url;
                        .....
ADSoft вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Download file Webclient Cpluser C# (си шарп) 1 16.07.2013 22:19
PHP download XML file Abuhamed PHP 2 10.06.2011 16:30
Создание Data Link File Volodq БД в Delphi 4 30.05.2011 10:17
Download File [WinSock] Denager Работа с сетью в Delphi 3 13.05.2010 13:01
Rss link to file Etlau PHP 0 20.05.2009 17:09