Php 使用Uploadify重命名文件的帮助
这是我的密码-Php 使用Uploadify重命名文件的帮助,php,database,file,upload,Php,Database,File,Upload,这是我的密码- <?php session_start(); include('connect.php'); mysqli_select_db($connect, "users"); $s = "select * from name where sessionusername = '$u'"; $q = mysqli_query($connect, $s); $f = mysqli_fetch_array($q); $name = $f['name']; if (!empty($_FIL
<?php
session_start();
include('connect.php');
mysqli_select_db($connect, "users");
$s = "select * from name where sessionusername = '$u'";
$q = mysqli_query($connect, $s);
$f = mysqli_fetch_array($q);
$name = $f['name'];
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
// $fileTypes = str_replace('*.','',$_REQUEST['fileext']);
// $fileTypes = str_replace(';','|',$fileTypes);
// $typesArray = split('\|',$fileTypes);
// $fileParts = pathinfo($_FILES['Filedata']['name']);
// if (in_array($fileParts['extension'],$typesArray)) {
// Uncomment the following line if you want to make the directory if it doesn't exist
// mkdir(str_replace('//','/',$targetPath), 0755, true);
// Get the extension, and build the file name
//$extension = pathinfo($tempFile, PATHINFO_EXTENSION);
$extension = end(explode(".",$_FILES['Filedata']["name"]));
$new_file_name = '".$name."'".".$extension;
$targetFile = str_replace('//','/',$targetPath) . $new_file_name;
// $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
move_uploaded_file($tempFile,$targetFile);
echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
// } else {
// echo 'Invalid file type.';
// }
}
是表单enctype=='multipart/form data'?啊,现在我明白你在说什么了。你应该删除你的其他帖子。这是我以前在Uploadify中遇到的一个错误,但我不确定这里到底发生了什么。当然,请签出您的enctype,但为了调试,我在这里使用Uploadify实现了错误报告解决方案:。哪个部分不起作用?是否正在生成错误?文件是实际上载还是为空?文件未上载。错误HTTP\U错误。请复制准确的错误消息。确保您的表单具有正确的enctype(多部分/表单数据)