Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Problema upload

  1. #1

    Problema upload

    uso questa sub per fare l'upload,ma se lo faccio da pc mi trasferisce il file con il nome C:\document etc...

    come skippo il percorso??

    codice:
    sub do_upload {
    
      my $submit = $q->param('submit') || undef;
    
      if ($submit)
      {
    
        my $file = $q->param('UPLOAD') || die "Error: (do_upload) You did not select a file!!\n$!";
           $file =~ m/^.*(\\|\/)(.*)/;
        my $name;
        $2 ? $name = $2 : $name = $file;
      
        my $upload_path = $target_upload . 'MYSIMPLENEWS/upload/' . $name;
      
        open(LOCAL, ">$upload_path") || die "Error: (do_upload) $upload_path\n$!";
        binmode(LOCAL);
        while(<$file>) {
            print LOCAL $_;
        }
        close(LOCAL);
      
        chmod (0644,"$upload_path");
      
        print "Content-type: text/html","\n\n";
        print qq~<html>L'immagine $name \&egrave; stata trasferita con successo!! (ora puoi chiudere questa finestra)</html>~;
    
      } else {
      
        print "Content-type: text/html","\n\n";
        print qq~
         <html>
         <head>
         <title>..:: MYSIMPLENEWS(1.9.3) ::..</title>
         <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
         </head>
         <body bgcolor="#FFFFFF" TOPMARGIN="10" LEFTMARGIN="15">
         <h2>Upload images:</h2>
         <form ENCTYPE="multipart/form-data" ACTION="mysimplenews.cgi" METHOD="POST">
         <input type="hidden" NAME="DO" VALUE="UPLOAD">
         
    
    Please select a file to upload: 
    
         <input type="file" NAME="UPLOAD">
         </p>
         <input type="submit" NAME="submit" value=" submit image ">
         </form>
         </body>
         </html>~;
        
      }
    
    }
    Credevo che $file =~ m/^.*(\\|\/)(.*)/; facesse al caso mio,ma invece no

  2. #2
    tanto per la cronaca:

    ($name) = ($file =~ m|([^\\/]+)$|);

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 © 2025 vBulletin Solutions, Inc. All rights reserved.