Ragazzi sto uscendo pazzo, qui di seguito vi riporto il codice per fare l'upload di un'immagine al server.
Dopo aver inserito il file e cliccato su invia, easyPhp mi da questo errore:
Warning: move_uploaded_file(/var/www/vhosts/xxxxxx/httpdocs/Banner/9/8/giochi-152943357.gif): failed to open stream: No such file or directory in c:\programmi\easyphp1-8\www\.........
Di seguito il form che invia i dati:
<label>Inserimento foto: </label>
<div>
<INPUT TYPE="file" NAME="userfile">
</div>
Di seguito è riportato il codice per l'upload:
$actnum = rand( 1,999999999999); $actnum2 = rand( 1,9); $actnum3 = rand( 1,9);
$fileName = $_FILES['userfile']['name']; // get client side file name
if ($fileName == "") die(" no ");
if( $fileName )
{
// Check File Type
$fileNameParts = explode( ".", $fileName ); // seperate the name from the ext
$fileExtension = end( $fileNameParts ); // part behind last dot
$fileExtension = strtolower( $fileExtension ); // reduce to lower case
if( $fileExtension != "gif" AND $fileExtension != "png" AND $fileExtension != "jpg" )
{
die( "no " );
}
// Check File Size
$fileSize = $_FILES['userfile']['size']; // size of uploaded file
if( $fileSize == 0 ) exit("Sorry. The upload of $fileName has failed. The file size is 0.");
else if( $fileSize > 1024000 )
{
//10 MB
die( " no " );
}
else
{
$uploadDir = '/var/www/vhosts/xxxx/httpdocs/Banner/' . $actnum2 . '/'. $actnum3. '/' ; // Where the temp file will go
$uploadFile = str_replace( " ", "", $uploadDir . $_FILES['userfile']['name'] ); // Get rid of spaces in the filename
$finalDir = '/var/www/vhosts/xxxx/httpdocs/Banner/'. $actnum2 . '/'. $actnum3. '/' ; // Where the final file will go
$finalFile = str_replace( " ", "", $finalDir . $fileNameParts[0] . $actnum . ".gif" ); // Get rid of spaces in the filename
if ( !move_uploaded_file( $_FILES['userfile']['tmp_name'], $finalFile ) )
{
echo ("");
}
}
}
Aspetto vostri suggerimenti

Rispondi quotando