[英]PHP Wait For Image Upload to Finish Before Resizing
Is there a way to "pause" php to wait for a file to upload before manipulating it? 有没有办法在操作之前“暂停”等待文件上传?
I am using this to upload photos: 我用它来上传照片:
move_uploaded_file($_FILES[$PhotoField]["tmp_name"], $BrandDirectory . "/" . $NewPhotoName);
That part seems to be working well. 那部分似乎运作良好。 The issue is that after that I am resizing the photo that is uploaded using:
问题是,之后我正在调整使用以下内容上传的照片:
$image = new SimpleImage();
$image->load($BrandDirectory . "/" . $NewPhotoName);
$image->resizeToWidth(1024);
$image->save($BrandDirectory . "/" . $NewPhotoName);
That part seems to work as well to, as long as the photo has finished uploading. 只要照片上传完毕,该部分似乎也可以正常工作。 So, it seems that I need some way for everything to wait before the upload finishes.
因此,似乎我需要一些方法让所有内容在上传完成之前等待。
if(move_uploaded_file($_FILES[$PhotoField]["tmp_name"], $BrandDirectory . "/" . $NewPhotoName)){
$image = new SimpleImage();
$image->load($BrandDirectory . "/" . $NewPhotoName);
$image->resizeToWidth(1024);
$image->save($BrandDirectory . "/" . $NewPhotoName);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.