我很难用 $_FILES
我想检查它是否为空,如果它不是空的,那么它不应该尝试上传文件.我该如何检查?
我有一个反应网络应用程序,在导航上有一个主题切换。我有一个ThemeProvider Context具有自动检测用户的系统主题首选项并设置它的逻辑。然而,我认为用户应该能够在网站上来回切换主题,无论他们的系统偏好如何。这是ThemeContext.js包含所有主题逻辑(包括方法)的文件toggle。
import React, { useState, useLayoutEffect } from 'react';
const ThemeContext = React.createContext({
dark: false,
toggle: () => {},
});
export default ThemeContext;
export function ThemeProvider({ children }) {
// keeps state of the current theme
const [dark, setDark] = useState(false);
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)')
.matches;
const prefersLight = window.matchMedia('(prefers-color-scheme: light)')
.matches;
const prefersNotSet = window.matchMedia(
'(prefers-color-scheme: no-preference)'
).matches;
// paints the app before it renders elements
useLayoutEffect(() => {
// Media …Run Code Online (Sandbox Code Playgroud) 我使用的 api 只允许使用id获取数据 ,但不允许 使用标题,如下所示http://0.0.0.0:5000/blog/13b03a39-bc04-4604-baf6-059658f9f5e8。端点返回一个 JSON 对象,我想使用 Next Js 将其渲染到浏览器。但是我想要一个干净的 url 架构,其中包含标题,如下所示:
而不是包含 id 的 url,如下所示:
这是我要传递的props方式Link:
<Link
href={`/post/${post.blog_title}`}
as={`/post/${post.blog_title}`}>
<a className='blog__card--link'>
<h4 className='blog__card--title'>{post.blog_title}</h4>
</a>
</Link>
Run Code Online (Sandbox Code Playgroud)
这是我的[id].js文件:
import { getBlog } from '../../api/index';
const Article = ({ blog }) => {
const router = useRouter();
return (
<div class='article'>
<div class='article__main'>
{/* {console.log(router)} */}
<ArticleView />
</div>
</div>
);
};
Article.getInitialProps = async (router) => {
const res …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Gmail API PHP 获取邮箱中所有附件的列表。我在某个时候卡住了,但我真的不知道在哪里。这是我用来获取消息内容的代码,当我尝试获取附件时,它以某种方式失败了。
我想获取与我的“q”查询对应的所有消息的文件名和附件 ID。这是我的代码:
function atta($service, $userId, $expeditor)
{
try
{
unset($optParamsamz);
$optParamsamz = [];
$optParamsamz['maxResults'] = 10; // Return Only 5 Messages
$optParamsamz['q'] = "has:attachment larger_than:10000000 "; // Only show messages in Inbox
$messagesamz = $service->users_messages->listUsersMessages('me',$optParamsamz);
$listamz = $messagesamz->getMessages();
$idlist = array();
foreach ($listamz as $key => $value) {
$message = $service->users_messages->get('me', $value['id']);
$array_message = $message->getPayload();
print_r($array_message);
echo "<br><br>";
}
}
catch (Exception $e)
{
print 'An error occurred: ' . $e->getMessage();
}
}
Run Code Online (Sandbox Code Playgroud) php ×2
reactjs ×2
api ×1
css ×1
file-upload ×1
gmail ×1
gmail-api ×1
input-field ×1
javascript ×1
next.js ×1
react-hooks ×1
validation ×1