Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Errore nella Lettura di un File

    Ho un semplice script che dovrebbe leggere da un sito:

    Codice PHP:
    //Leggiamo il contenuto del sito
    $handle fopen("http://www.example.it/index.html"'r');

    //Legge solo 4096 bytes partendo da un offset di 4096 bytes
    $data stream_get_contents($handle40964096)

    //Chiude lo stream
    fclose($handle); 
    La signature di stream_get_contents è:

    string stream_get_contents ( resource handle [, int maxlength [, int offset]] )

    Ma quando vado ad eseguire mi da il seguente errore:

    codice:
    Warning: stream_get_contents() [function.stream-get-contents]: stream does not support seeking in C:\wamp\www\videogames\include\test.php on line 23
    
    Warning: stream_get_contents() [function.stream-get-contents]: Failed to seek to position 4096 in the stream. in C:\wamp\www\videogames\include\test.php on line 23
    Invece provando ad eseguire degli esempi trovati su internet funziona tutto bene, ad esempio:

    Codice PHP:
    if ($stream fopen('http://www.example.com''r')) {
        
    // print all the page starting at the offset 10
        
    echo stream_get_contents($stream, -110);

        
    fclose($stream);

    Non riesco a capire dove sbaglio

  2. #2
    Ciao,
    guardando il codice che hai riportato mi sembra tutto corretto.

    quindi mi sorgono un paio di dubbi:
    1) http://www.example.it/index.html: la pagina index.html esiste?
    2) mi è capitato che nel il mio vecchio spazio Web la fopen fu disabilitata per questioni di sicurezza.
    Se vuoi ho scritto un articoletti su come leggere file remoti in maniera diversa,
    se ti interessa è qui:
    http://mirkoagrati.110mb.com/articol...t1.php&dir=PHP

    Ciao
    Mirko Agrati
    WEB : http://mirkoagrati.110mb.com
    RSS : http://feeds.feedburner.com/MirkoAgratiArticoli

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.