【问题标题】:Classe_upload.php construct session emptyClasse_upload.php 构造会话为空
【发布时间】:2013-06-21 13:11:14
【问题描述】:

我正在使用这个类:http://php.developpez.com/telecharger/detail/id/2944/Classe-d-upload-de-fichiers-avec-options-de-redimensionnement-renommage-gestion-des-erreurs

当我使用以下代码时:

$repertoire_destination = strtolower($_SESSION['login']);

 //Déclaration de la classe
 $up = new Telechargement($repertoire_destination,'form1','file','controle_form');

 //Extensions autorisées (sans les .)
 $extensions = array("gif","png","jpg","jpeg");
 $up->Set_Extensions_accepte ($extensions);

 $name_fichier = uniqid($_SESSION['login']);
 // Rennommage des fichiers (en mode incrémentiel) si déjà présents sur le serveur.
 $up->Set_Nomme_fichier($name_fichier,pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION));
 $up->Set_Renomme_fichier($name_fichier);

 $up->Set_Redim ('1920','1200');
 $up->Set_Redim ('160','100','upload/'.strtolower($_SESSION['login']).'/thumb');


 // Téléchargement
 $up->Upload();

上传的文件必须保存在目录:strtolower($_SESSION['login']); 其中$_SESSION['login']) 包含用户名。

但不幸的是,它发送了一个空值。

以后用的时候:

$up->Set_Redim ('160','100','upload/'.strtolower($_SESSION['login']).'/thumb');

$_SESSION['login']) 包含 username

谁能帮我解决这个问题?

【问题讨论】:

  • 我懂法语,并且通过您为您的课程提供的链接,我担心许多其他人将无法阅读/理解该页面内的内容。我会看看我能做些什么来帮助你,但不能向你保证任何事情。尝试找到等效的英文链接。
  • 是的,我知道...但不幸的是它不存在,我没有时间打开其他上传类。
  • 现在,session_start(); 是否存在/包含在您正在使用的所有 .php 文件中?如果使用会话,则必须包含它,并且它必须位于最顶部,在您的开始 PHP 标记 <?php 下方。这经常被忽视。
  • 请提供英文的变量名和cmets
  • 是的,你说得对......我没有考虑到这一点,因为第二次会话返回值。谢谢!

标签: php session upload


【解决方案1】:

session_start(); 如果使用会话,则必须存在/包含在所有 .php 文件中。

另外,它需要位于最顶端(大部分时间), 在您的 PHP 起始标签 <?php 下方。

这一点经常被忽视。

有关会话的更多信息,请访问以下链接,在 PHP.net 网站上找到。

http://php.net/manual/en/function.session-start.php

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-24
    • 2019-08-29
    • 2020-11-09
    • 2016-10-15
    • 1970-01-01
    • 2012-05-24
    相关资源
    最近更新 更多